Pika Variables
You can use various special variables in your posts and pages to do things like add some recent blog posts to a custom home page. Note: They don’t work inside inline code or code blocks. Here’s what Pika supports:
- Blog post variables
- Blog tag variables
- Letterbird contact form variable
- Newsletter subscribe form variable
- Search form variable
- Table of contents variable
Output your blog posts
There are three variables to output your blog posts:
- {{ posts }} and {{ posts_by_year }} output your posts in a list layout.
- {{ posts_in_stream }} outputs your posts in a stream layout.
They can all be customized by a number of parameters, like this example:
{{ posts limit: 10 skip: 5 tag: "Bill Murray" without_tag: "Chevy Chase" has_title: yes sent_as_newsletter: no sort: alpha }}
Note: These variables do not currently offer pagination.
Optional parameters
limit- Maximum number of posts to display. If not specified, defaults to 500 for post list variables and 20 for post stream variables. The maximum number of posts to display is 500 for post list variables and 50 for post stream variables.
skip- Skip the first n posts.
tag- Only include posts with the specified tag.
without_tag- Exclude posts with the specified tag.
has_titleyes(only posts with titles) orno(only posts without titles).sent_as_newsletteryes(only posts sent as newsletters) orno(only posts not sent as newsletters).sort- Use
alphato override the default sorting by date. This parameter only works with the {{ posts }} variable. with_excerpts- Use
noto override the default, which isyes(showing excerpts with “Continue reading” links). This parameter only works with the {{ posts_in_stream }} variable.
Output your blog tags
There are two variables to output your blog post tags:
- {{ tags }} outputs an alphabetical, comma-separated list of your blog tags.
- {{ tag_list }} outputs an alphabetical HTML list of your blog tags.
Optional parameters
separator- Use a custom tag separator in place of a comma in the {{ tags }} variable. Example: {{ tags separator: " | " }}
Output your Letterbird contact form
Letterbird is another service from Good Enough that allows you to create a simple contact form. While it has its own embed code, Pika has a first-class variable for you to embed your form (like on a contact page):
{{ letterbird_form user: yourusername }}
Optional parameters
user- Your Letterbird username. This is a required parameter.
showheader- Include your Letterbird form header.
Output your Newsletter subscribe form
While there’s an option in Newsletter Settings to automatically include your subscription form on your site, you can also embed your form anywhere with this variable:
{{ newsletter_subscription_form }}
There are no parameters for this variable.
Output your Search form
If you have Site Search enabled, you can embed a search form anywhere with this variable:
{{ search_form }}
There are no parameters for this variable.
Output a table of contents
Automatically generate a linked table of contents from all the headings (h1–h6) in the body of your post or page:
{{ table_of_contents }}
It can be customized by a couple of parameters, like this example:
{{ table_of_contents heading: "On This Page" only_headers: "h2 h3" }}
Optional parameters
heading- A title to display above the table of contents as an H2, which is not included in the table of contents list itself.
only_headers- A space-separated list of heading levels (h1-h6) to include.