Skip to content
Honmaple
Documentation navigation

Pages

On this page

A Page is Snow's basic unit of content.

Create a Page

Add a content file under content/. See Parsers for supported extensions and configuration.

content/
├── about.md              # Page → /about/
└── posts/
    ├── hello.md           # → /posts/hello/
    └── bundle/            # Page bundle
        ├── index.md       # → /posts/bundle/
        └── image.png      # Attachment

A directory containing index.{md,org,html} is a page bundle. Other files in it can be used as attachments.

Front Matter

---
title: "Article title"
slug: "custom-slug"
date: 2024-01-15 20:35:00
modified: 2024-02-01 10:00:00
draft: false
hidden: false
render: true
path: "custom/url/"
template: "custom-post.html"
aliases:
  - "/old-url/"
tags:
  - go
  - web
categories:
  - Programming/Go
---

Fields

Field Type Description
title string Page title
slug string URL slug
date datetime Creation date
modified datetime Modification date
draft bool Excluded from normal builds when true
hidden bool Hidden from regular page lists
render bool Whether to render the page
path string Custom output path
template string Custom template
aliases []string Redirect aliases
assets []string Attachment allowlist for a page bundle
formats.{name}.path string Additional format's output path
formats.{name}.template string Additional format's template
{taxonomy} any A taxonomy field, such as tags or authors

Page Configuration

pages:
  _default:
    path: "{path:slug}/{slug}/"
  posts:
    path: "articles/{date:%Y}/{date:%m}/{slug}.html"
  pages:
    hidden: true
    template: "page.html"
  en:
    lang: "en"
  drafts:
    draft: true

Settings are looked up in pages.{directory-path}, then parent directories, then pages._default.

Path Variables

Variable Meaning Example
{date:%Y} Four-digit year 2024
{date:%m} Month 01
{date:%d} Day 15
{date:%H} Hour 20
{lang} Language code en
{lang:optional} Language code; empty for the default language en or empty
{path} Source directory path posts
{path:slug} Slugified directory path posts
{slug} Page slug hello-world
{title} Page title Hello World

{path[start:end]} selects directory segments separated by /. Indexes are zero-based; the start is inclusive and the end exclusive. An omitted start means zero; an omitted end means the directory's full depth. Use integers without leading zeroes, between zero and the directory depth. Empty ranges produce an empty string; out-of-range placeholders remain unchanged.

Append :slug to slugify each selected segment. For Docs/Guide Book/API Reference, {path[1:]:slug} produces guide-book/api-reference.

For docs/note/2006/guide, {path[:2]} is docs/note and {path[3:]} is guide. Use /{lang:optional}/{path[:2]}/{path[3:]}/{slug}/ to omit the year directory from page URLs.

Template Lookup

  1. The front matter template value.
  2. page.html.

Template Variables

Property Type Description
page.File File Source file information
page.File.Path string File path relative to the content root
page.File.Dir string Source directory
page.File.Name string Filename
page.File.BaseName string Filename without its extension
page.File.LanguageName string Language from mount metadata or the filename suffix
page.File.Ext string File extension
page.FrontMatter FrontMatter Metadata
page.FrontMatter.{xxx} any A custom metadata field
page.Toc []Heading Table of contents
page.Lang string Language code
page.Slug string URL slug
page.Title string Title
page.Description string Description
page.Summary string Summary
page.Content string Rendered HTML
page.RawContent string Original content
page.Draft bool Whether this is a draft
page.Hidden bool Whether this is hidden
page.IsBundle bool Whether this is a page bundle
page.WordCount int64 Word count
page.ReadingTime int64 Estimated reading time in minutes
page.Date time.Time Creation date
page.Modified time.Time Modification date
page.Path string Relative URL
page.Permalink string Absolute URL
page.Section Section Owning section
page.Assets Assets Bundle attachments
page.Formats Formats Additional output formats
page.Ancestors() Sections Sections starting at the owning section and going upward, excluding the page

Related values:

Property Description
page.Section.Title Owning section's title
page.Assets[n].Path Attachment's relative output URL
page.Assets[n].Permalink Attachment's absolute output URL
page.Formats.Find("rss") Find a format by name

Drafts

Set draft: true in front matter, or mark a directory in configuration:

pages:
  drafts:
    draft: true

Drafts are excluded by default. Use --include-drafts to include them.