Twig Variables

Twig exposes many variables that you can make use of in twig 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.

VariableDescription
site.urlAbsolute URL to the blog.
site.nameName of the blog.
site.descriptionDescription of the blog.
site.feed_urlRSS feed URL for the blog.
site.emailEmail address associated with the blog.
site.timezoneLocal timezone of the site.
site.can_registertrue if visitors can register as users.
site.comments_per_pageNumber of comments per page.
theme.urlAbsolute 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_timeTotal 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.paginatedObject containing the posts for this page of the index.
post.featherName of the Feather responsible for rendering a blog post.
post.idUnique identifier for a blog post.
post.created_atTimestamp for the creation of a blog post.
post.updated_atTimestamp for the most recent update of a blog post.
post.urlThe unique URL (slug) for a blog post.
post.slugSynonym for post.url.
post.url()Generates a fully qualified URL permalink for a blog post.
post.titleTitle of 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.idUnique identifier for a page.
page.created_atTimestamp for the creation of a page.
page.updated_atTimestamp for the most recent update of a page.
page.urlThe unique URL (slug) for a page.
page.slugSynonym for page.url.
page.url()Generates a fully qualified URL permalink for a page.
page.titleTitle of a page.
page.publicCan the page be viewed without permission?
page.show_in_listShould the page be included in the pages list?
route.actionCurrent route action, e.g. "index" or "login".
nowLocal time on the web server measured in seconds since the Unix Epoch.
GETGET parameters sent by the web browser when the page was requested.
POSTPOST parameters sent by the web browser when the page was requested.
sql_queriesTotal number of SQL database queries to complete this page request.
sql_debugArray of the SQL database queries made during this page request.
reasonOften defined and contains an error message if an expected variable is missing.