Skip to content
Honmaple
Documentation navigation

Output Formats

On this page

Sections, Pages, and taxonomy terms can generate additional output such as RSS, Atom, and JSON.

Global Defaults

formats:
  rss:
    template: "partials/rss.xml"
  atom:
    template: "partials/atom.xml"

These define default templates. Individual content types supply their output paths.

Section Formats

Configure formats in the section's front matter:

# _index.md
---
formats:
  rss:
    path: "posts/index.xml"
  atom:
    path: "posts/atom.xml"
  json:
    path: "posts/index.json"
    template: "custom.json"
---

An empty path disables a format. If template is omitted, the global default is used.

Page Formats

---
formats:
  json:
    path: "api/articles/hello.json"
    template: "article.json"
---

Taxonomy Term Formats

taxonomies:
  tags:
    term:
      formats:
        atom:
          path: "tags/{term:slug}/atom.xml"
          template: "custom.atom.xml"

Format Settings

Define each format beneath formats.{name}. Supply path and optionally template; the template falls back to the global formats.{name}.template. A format is skipped if either the resulting path or template is empty.

Template Variables

Format templates have access to global values and functions, including pages, sections, taxonomies, and get_pages([lang]).

Content Type Current Object Local Page Collection
Section section section.Pages
Page page None
Taxonomy term term, taxonomy term.Pages

pages always means all regular pages in the current language. It is not an alias for a section or term's pages.

RSS Example

templates/partials/rss.xml:

<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0">
  <channel>
    <title>{{ config.title }}</title>
    <link>{{ config.base_url }}</link>
    <description>{{ config.description }}</description>
    {% for page in section.Pages %}
    <item>
      <title>{{ page.Title }}</title>
      <link>{{ page.Permalink }}</link>
      <pubDate>{{ page.Date | date:"Mon, 02 Jan 2006 15:04:05 -0700" }}</pubDate>
      <description>{{ page.Summary }}</description>
    </item>
    {% endfor %}
  </channel>
</rss>

Atom Example

<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
  <title>{{ config.title }}</title>
  <link href="{{ config.base_url }}/atom.xml" rel="self"/>
  <updated>{{ section.Pages[0].Date | date:"2006-01-02T15:04:05Z07:00" }}</updated>
  <id>{{ config.base_url }}/</id>
  {% for page in section.Pages %}
  <entry>
    <title>{{ page.Title }}</title>
    <link href="{{ page.Permalink }}"/>
    <id>{{ page.Permalink }}</id>
    <published>{{ page.Date | date:"2006-01-02T15:04:05Z07:00" }}</published>
    <content type="html">{{ page.Content }}</content>
  </entry>
  {% endfor %}
</feed>