Twig Variables
Twig exposes many variables that you can make use of in template files. Below is a non-exhaustive list of the most frequently used variables. You can have Twig display these variables on your web pages, and you can reference them in your Twig code. In addition to those listed below, enabled extensions may expose further variables for your use.
You can use Twig's filter functions to explore, transform, and format Twig variables.
Variable | Description |
---|---|
site.url |
Absolute URL to the blog. |
site.name |
Name of the blog. |
site.description |
Description of the blog. |
site.feed_url |
RSS feed URL for the blog. |
site.email |
Email address associated with the blog. |
site.timezone |
Local timezone of the site. |
site.can_register |
true if visitors can register as users. |
site.comments_per_page |
Number of comments per page. |
theme.url |
Absolute URL to the theme directory. |
theme.recent_posts() |
Returns an array of the 5 most recent blog posts. |
theme.related_posts(post) |
Returns an array of 5 posts related to the supplied post. |
theme.pages_list() |
Returns an array of the site's pages. |
theme.archives_list() |
Returns an array of links to the monthly blog archives. |
theme.feeds() |
Generates a <link> for each of your blog's RSS feeds. |
theme.stylesheets() |
Generates a <link> for every file in the stylesheets directory. |
theme.javascripts() |
Generates a <link> for every file in the javascripts directory. |
theme.load_time |
Total server load time to complete this page request. |
posts.prev_link() |
Generates <a> tag for earlier posts in the index. |
posts.next_link() |
Generates <a> tag for newer posts in the index. |
posts.paginated |
Object containing the posts for this page of the index. |
post.feather |
Name of the Feather responsible for rendering a blog post. |
post.id |
Unique identifier for a blog post. |
post.created_at |
Timestamp for the creation of a blog post. |
post.updated_at |
Timestamp for the most recent update of a blog post. |
post.url |
The unique URL identifier (slug) for a blog post. |
post.slug |
Synonym for post.url . |
post.url() |
Generates a fully qualified URL permalink for a blog post. |
post.title() |
Generates a title for a blog post from the title (if any) or contents. |
post.previous.url() |
Generates a URL for the previous blog post in chronological order. |
post.next.url() |
Generates a URL for the next blog post in chronological order. |
page.id |
Unique identifier for a page. |
page.created_at |
Timestamp for the creation of a page. |
page.updated_at |
Timestamp for the most recent update of a page. |
page.url |
The unique URL (slug) for a page. |
page.slug |
Synonym for page.url . |
page.url() |
Generates a fully qualified URL permalink for a page. |
page.title |
Title of a page. |
page.public |
Can the page be viewed without permission? |
page.show_in_list |
Should the page be included in the pages list? |
route.action |
Current route action, e.g. "index" or "login". |
now |
Local time on the web server measured in seconds since the Unix Epoch. |
GET |
GET parameters sent by the web browser when the page was requested. |
POST |
POST parameters sent by the web browser when the page was requested. |
sql_queries |
Total number of SQL database queries to complete this page request. |
sql_debug |
Array of the SQL database queries made during this page request. |
reason |
Defined and contains an error message if a 404 or 403 is encountered. |