Variables

As mentioned in the Context section, Aoife makes available a number of variables to template files through their context. The following variables are available for use in template files within a theme.

Site variables

The value of any variable in the site’s config.json file can be retrieved from any template file with the tag {{site.VARIABLE_NAME} }, this includes user-defined variables. This is the prefered method to set global data values.

For example, to get the base URL of the entire site from within a template file, simply use the tag {{site.baseURL} }.

Single and list variables

The following is a list of the variables available to both single.html and list.html template files. In the case of single content, all may be overridden in the frontmatter. Remember, these are all accessed by enclosing in double curly braces, e.g.{{variable name} }.

  • assets The URL to this theme’s assets/ folder
  • date The date of the content in SQL format
  • date.second The second component of the content’s date (two digits)
  • date.minute The minute component of the content’s date (two digits)
  • date.hour The hour component of the content’s date (two digits)
  • date.day The day component of the content’s date (two digits)
  • date.month The month component of the content’s date (two digits)
  • date.shortMonth The month component of the content’s date (e.g. Jan)
  • date.longMonth The month component of the content’s date (e.g. January)
  • date.year The year component of the content’s date (four digits)
  • feedURL The URL to the site’s RSS feed (if enabled in the site’s config.json)
  • permalink The permalink to this content
  • navigation An HTML unordered list of the site contents
  • title The title of the content

Single post variables

The following is a list of the variables only accessible from within a single.html template file. Additionally, any variable described in the frontmatter will also be available.

  • content The actual content (process Markdown)
  • readingTime Estimated reading time for the content (e.g. “3 min read”)
  • summary A summary of the content
  • wordCount The number of words in the content (e.g. “500 words”)

If the frontmatter of a post is as follows:

;;;
"author": "Garry Pettet",
"rating": 5
;;;

Then we can access these frontmatter variables from within a single.html template file like this:

<p>Author is: {{author} }</p>
<p>Rating is: {{rating} } stars</p>

Which will unsurprisingly render as:

<p>Author is: Garry Pettet</p>
<p>Rating is: 5 stars</p>

List page variables

List pages are automatically created by Aoife at the root of the site as http://example.com/index.html (unless a static homepage is specified) and at the root of every section (e.g. http://example.com/review/index.html) and are rendered by the list.html template file. The following is a list of variables accessible from list.html template files.

  • {{nextPage} } The URL to the next page in a paginated list of posts
  • {{prevPage} } The URL to the previous page in a paginated list of posts

Archive variables

If you have asked Aoife to build archives then you may have a need for the {{archives.VALUE} } tag. There are four tags:

  • {{archives.url} } The URL to your site’s archive listing page (e.g. http://example.com/archive/)
  • {{archives.months} } An HTML list of your site’s content by year
  • {{archives.longMonths} } An HTML list of your site’s content by month (e.g. January)
  • {{archives.years} } An HTML list of your site’s content by month (e.g. Jan)

Helper variables

There are a number of miscellaneous tags that can be called from any template file. They are all prefixed with helper.

  • {{helper.day} } The current day of the month (two digits)
  • {{helper.longMonth} } The current month (e.g. January)
  • {{helper.shortMonth} } The current month (e.g. Jan)
  • {{helper.month} } The current month (two digits)
  • {{helper.year} } The current year (four digits)

Aoife variables

  • {{aoife.generator} } Meta tag for the version of Aoife that built the site. I’d be very grateful if you would include it in all theme headers so I can track the usage and popularity of Aoife as a tool. Example output: <meta name="generator" content="Aoife 0.9.0" />
  • {{aoife.version} } Aoife’s version number

Modified: Dec 8, 2016 at 19:53:39

Aoife v0.9.0 documentation