Template Variables by Context

On this page

Different routes in Aether provide different variables to templates. Here's a comprehensive breakdown of available variables in various contexts.

Global Variables (Available in All Templates)

These variables are available in every template through the prepareTemplateData function:

Variable Type Description Example
site Object Complete site settings {siteTitle: "My Site", siteDescription: "...", postsPerPage: 10}
theme Object Active theme information {name: "default", info: {title: "Default Theme", version: "1.0.0"}}
year Number Current year 2024
editable Boolean Whether user can edit content true
currentUser Object/null Current logged-in user data {username: "admin", role: "admin"}
aetherBar String Admin bar HTML (if user has edit permissions) "<div class='aether-bar'>..."
html_menu String Generated navigation menu HTML "<nav class='site-navigation'>..."
menuItems Array Raw menu items data [{id: "home", title: "Home", url: "/"}]

Home Page Variables

Route: /
Source: home.js

Variable Type Description Notes
posts Array Recent published posts with metadata Limited by postsPerPage setting
homeRoute Boolean Flag for home page Always true
content String Homepage content (if custom homepage.html exists) Only when custom homepage template is used
metadata Object Homepage frontmatter (if custom homepage.html exists) Only when custom homepage template is used

Single Post Variables

Route: /post/:slug
Source: content.js

Variable Type Description Notes
content String Post content (HTML) Processed through marked
metadata Object Post frontmatter All post metadata fields
fileType String Content type Always "post"
contentRoute Boolean Flag for content page Always true
contentId String Post ID Used for editing links
prevPost Object/null Previous post reference {title: "...", slug: "..."}
nextPost Object/null Next post reference {title: "...", slug: "..."}
relatedPostsData Array Related posts data (if configured) [{id, title, subtitle, slug, featuredImage, excerpt}]

Page Variables

Route: /page/:slug
Source: content.js

Variable Type Description Notes
content String Page content (HTML) Processed through marked
metadata Object Page frontmatter All page metadata fields
fileType String Content type Always "page"
contentRoute Boolean Flag for content page Always true
contentId String Page ID Used for editing links
isCustomPage Boolean Whether page is custom type true for custom pageType

Category Archive Variables

Route: /category/:slug
Source: taxonomy.js

Variable Type Description Notes
posts Array Posts in category with metadata Paginated results
fileType String Content type Always "category"
taxonomyType String Taxonomy type Always "category"
taxonomyTerm String Category slug The category being displayed
pagination Object Pagination data with URLs Includes prev/next page links
taxonomyRoute Boolean Flag for taxonomy page Always true
categoryName String Category slug Same as taxonomyTerm
metadata Object Custom template metadata (if using custom/category.html) Title, description, etc.
content String Custom template content (if using custom/category.html) Processed markdown content

Tag Archive Variables

Route: /tag/:slug
Source: taxonomy.js

Variable Type Description Notes
posts Array Posts with tag with metadata Paginated results
fileType String Content type Always "tag"
taxonomyType String Taxonomy type Always "tag"
taxonomyTerm String Tag slug The tag being displayed
pagination Object Pagination data with URLs Includes prev/next page links
taxonomyRoute Boolean Flag for taxonomy page Always true
tagName String Tag slug Same as taxonomyTerm
metadata Object Custom template metadata (if using custom/tag.html) Title, description, etc.
content String Custom template content (if using custom/tag.html) Processed markdown content

Custom Page Variables

Routes: /:path, /:path/:subpath, /:path/:subpath/:subSubPath
Source: custom.js

Base Custom Page Variables

Variable Type Description Notes
customPath String Full URL path e.g., "docs/api/examples"
content String Page content (HTML) Processed through marked
metadata Object Page frontmatter All page metadata fields
fileType String Content type Always "page"
contentRoute Boolean Flag for content page Always true
contentId String Page ID Used for editing links
isCustomPage Boolean Custom page flag Always true
isCustomTemplate Boolean Custom template flag Always true
recentPosts Array Recent posts (for non-paginated templates) Limited to 5 posts

Nested Custom Page Variables

For nested pages (e.g., /docs/api/examples):

Variable Type Description Notes
parentPage Object/null Parent page data {title: "...", slug: "..."}
breadcrumbs Array Breadcrumb navigation [{title, slug, order, active?}]
siblingNavigation Object/null Sibling page navigation {siblings: [], prev: {}, next: {}, parentTitle: "..."}

Special Custom Template Variables

Pagination Templates

Templates: blog.html, archive.html, articles.html, news.html, search.html

Variable Type Description Notes
posts Array Paginated posts with metadata All published posts, paginated
pagination Object Pagination data with URLs Complete pagination object

Taxonomy Count Templates

Templates: categories.html, tags.html, topics.html

Variable Type Description Notes
categories/tags Array Taxonomy items with counts [{name, slug, count, posts?}]
taxonomies Array Same as above (alias) For generic template usage
taxonomiesType String Type of taxonomies "categories" or "tags"
taxonomyType String Singular form "category" or "tag"
hasTaxonomyData Boolean Data availability flag Always true

Error Page Variables

Routes: 404 and 500 errors
Source: route-utils.js

Variable Type Description Notes
notFoundRoute Boolean 404 error flag true for 404 pages
serverErrorRoute Boolean 500 error flag true for 500 pages
metadata Object Error page metadata Includes title and description

Static Site Generation Variables

Source: static-generator.js

Additional variables available during static site generation:

Variable Type Description Notes
isGenerateStatic Boolean Static generation flag true during SSG

Hook System Variables

Templates can receive additional variables through the hook system. The following hooks can modify template data:

  • template_data - Global template data filter
  • api_posts - Posts data filter (for API endpoints)
  • api_pages - Pages data filter (for API endpoints)
  • api_post - Single post data filter (for API endpoints)

Pagination Object Structure

The pagination object available in taxonomy and custom templates contains:

{
  currentPage: 1,
  totalItems: 25,
  pageSize: 10,
  totalPages: 3,
  prevPage: null,
  nextPage: 2,
  urls: {
    first: "/category/tech",
    prev: null,
    current: "/category/tech",
    next: "/category/tech/page/2",
    last: "/category/tech/page/3"
  }
}

Menu Items Structure

The menuItems array contains menu objects with this structure:

[
  {
    id: "home",
    title: "Home",
    url: "/",
    order: 1,
    parent: null,
    hasChildren: false,
    depth: 0
  }
]

Sibling Navigation Structure

The siblingNavigation object for nested custom pages contains:

{
  siblings: [
    {title: "Page 1", slug: "page-1", url: "/docs/page-1", active: false, order: 0},
    {title: "Page 2", slug: "page-2", url: "/docs/page-2", active: true, order: 1}
  ],
  prev: {title: "Page 1", slug: "page-1", url: "/docs/page-1", order: 0},
  next: null,
  parentTitle: "Documentation"
}

Performance Notes

  • All arrays are pre-filtered and sorted where appropriate
  • Metadata objects exclude sensitive information (like password hashes)
  • Content is pre-processed through the Marked parser for HTML output
  • File existence checks are cached during template resolution