Templates
Beemo uses Chameleon page templates (*.pt
files). All site build templates receive a site argument — an instance of
SiteData — as well as post and page arguments (one will be the relevant
content object for that template; the other will be None). This allows the layout template to
detect context regardless of which template is active. Template-specific variables are listed below.
The site instance exposes the following attributes that templates commonly use:
Attribute |
Description |
|---|---|
|
The homepage object, or |
|
All posts, sorted by |
|
All pages (if in pages mode) |
|
Dict mapping year (int) to a list of posts published in that year |
|
Dict mapping tag name → list of posts, sorted by number of posts then alphabetically |
|
The active build configuration |
|
The current UTC datetime (set at build time) |
Site build templates
These templates are placed in your configured templates_dir.
layout
File: layout.pt
The layout template is not rendered directly. It defines a layout macro that is passed into
all other site build templates so they can share a common page structure.
home
File: home.pt
Used for: the site homepage (index.html).
Variable |
Description |
|---|---|
|
The |
|
The homepage |
|
The |
page
File: page.pt
Used for: each individual page (one per page in pages_dir). A page can override this with
a template field in its meta.yml.
Variable |
Description |
|---|---|
|
The |
|
The |
|
The |
post
File: post.pt
Used for: each individual blog post. A post can override this with a template field in its
meta.yml.
Variable |
Description |
|---|---|
|
The |
|
The |
|
The previous (older) |
|
The next (newer) |
|
Always |
|
The |
blog
File: blog.pt (optional)
Used for: the blog index page. If blog.pt does not exist, the posts template is used
instead (see below).
Variable |
Description |
|---|---|
|
The |
|
Page title ( |
|
Path to the blog root |
|
The |
posts
File: posts.pt
Used for: the blog index (fallback when blog.pt is absent), year archive pages, month
archive pages, and tag pages.
Variable |
Description |
|---|---|
|
The |
|
Page title (e.g. |
|
Path to this listing page |
|
List of |
|
The |
archive
File: archive.pt
Used for: the full blog archive page.
Variable |
Description |
|---|---|
|
The |
|
Page title ( |
|
Path to the archive page |
|
The |
sitemap
File: sitemap.pt
Used for: generating sitemap.xml.
Variable |
Description |
|---|---|
|
The |
|
Set of years (integers) that have posts |
|
Set of |
atom
File: atom.pt
Used for: generating the Atom feed (<blog_root>/atom.xml).
Variable |
Description |
|---|---|
|
The |
Post and Page objects
Both Page and Post share the following attributes:
Attribute |
Description |
|---|---|
|
Post or page title |
|
Rendered HTML content |
|
Plain text content (HTML tags stripped) |
|
Short excerpt (auto-derived from |
|
Meta description (defaults to |
|
URL slug (derived from the content directory name) |
|
Path relative to the output root |
|
List of image file paths from the |
|
Optional cover image filename |
|
Optional Open Graph image filename |
|
Optional author name |
Post has these additional attributes:
Attribute |
Description |
|---|---|
|
Publication datetime (UTC) |
|
Last-modified datetime (defaults to |
|
|
|
List of tag strings |