zola/documentation/templates/feeds/index.html
2024-12-29 16:53:47 +00:00

339 lines
20 KiB
HTML

<!DOCTYPE html>
<html lang="en-gb">
<head>
<meta charset="UTF-8">
<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="description" content="Everything you need to make a static site engine in one binary.">
<meta name="author" content="Vincent Prouillet">
<title>Feeds | Zola </title>
<link rel="stylesheet" href="https://www.getzola.org/site.css">
<link rel="icon" href="https://www.getzola.org/favicon.ico">
</head>
<body>
<header>
<a class="header__logo white" href="https:&#x2F;&#x2F;www.getzola.org&#x2F;">Zola</a>
<nav>
<ul>
<li><a class="white" href="https://www.getzola.org/documentation/" class="nav-link">Docs</a></li>
<li><a class="white" href="https://www.getzola.org/themes/" class="nav-link">Themes</a></li>
<li><a class="white" href="https://zola.discourse.group/" class="nav-link">Forum</a></li>
<li><a class="white" href="https://github.com/getzola/zola" class="nav-link">GitHub</a></li>
</ul>
<div class="search-container">
<input id="search" type="search" placeholder="🔎 Search the docs">
<div class="search-results">
<div class="search-results__items"></div>
</div>
</div>
</nav>
</header>
<div class="content content--reversed">
<div class="documentation">
<aside class="documentation__sidebar">
<ul>
<li>
<span class="documentation__sidebar__title">Getting Started</span>
<ul>
<li class="">
<a href="https:&#x2F;&#x2F;www.getzola.org&#x2F;documentation&#x2F;getting-started&#x2F;overview&#x2F;">Overview</a>
</li>
<li class="">
<a href="https:&#x2F;&#x2F;www.getzola.org&#x2F;documentation&#x2F;getting-started&#x2F;installation&#x2F;">Installation</a>
</li>
<li class="">
<a href="https:&#x2F;&#x2F;www.getzola.org&#x2F;documentation&#x2F;getting-started&#x2F;cli-usage&#x2F;">CLI usage</a>
</li>
<li class="">
<a href="https:&#x2F;&#x2F;www.getzola.org&#x2F;documentation&#x2F;getting-started&#x2F;directory-structure&#x2F;">Directory structure</a>
</li>
<li class="">
<a href="https:&#x2F;&#x2F;www.getzola.org&#x2F;documentation&#x2F;getting-started&#x2F;configuration&#x2F;">Configuration</a>
</li>
</ul>
</li>
<li>
<span class="documentation__sidebar__title">Content</span>
<ul>
<li class="">
<a href="https:&#x2F;&#x2F;www.getzola.org&#x2F;documentation&#x2F;content&#x2F;overview&#x2F;">Overview</a>
</li>
<li class="">
<a href="https:&#x2F;&#x2F;www.getzola.org&#x2F;documentation&#x2F;content&#x2F;section&#x2F;">Section</a>
</li>
<li class="">
<a href="https:&#x2F;&#x2F;www.getzola.org&#x2F;documentation&#x2F;content&#x2F;page&#x2F;">Page</a>
</li>
<li class="">
<a href="https:&#x2F;&#x2F;www.getzola.org&#x2F;documentation&#x2F;content&#x2F;shortcodes&#x2F;">Shortcodes</a>
</li>
<li class="">
<a href="https:&#x2F;&#x2F;www.getzola.org&#x2F;documentation&#x2F;content&#x2F;linking&#x2F;">Internal links &amp; deep linking</a>
</li>
<li class="">
<a href="https:&#x2F;&#x2F;www.getzola.org&#x2F;documentation&#x2F;content&#x2F;table-of-contents&#x2F;">Table of Contents</a>
</li>
<li class="">
<a href="https:&#x2F;&#x2F;www.getzola.org&#x2F;documentation&#x2F;content&#x2F;syntax-highlighting&#x2F;">Syntax Highlighting</a>
</li>
<li class="">
<a href="https:&#x2F;&#x2F;www.getzola.org&#x2F;documentation&#x2F;content&#x2F;taxonomies&#x2F;">Taxonomies</a>
</li>
<li class="">
<a href="https:&#x2F;&#x2F;www.getzola.org&#x2F;documentation&#x2F;content&#x2F;search&#x2F;">Search</a>
</li>
<li class="">
<a href="https:&#x2F;&#x2F;www.getzola.org&#x2F;documentation&#x2F;content&#x2F;sass&#x2F;">Sass</a>
</li>
<li class="">
<a href="https:&#x2F;&#x2F;www.getzola.org&#x2F;documentation&#x2F;content&#x2F;image-processing&#x2F;">Image processing</a>
</li>
<li class="">
<a href="https:&#x2F;&#x2F;www.getzola.org&#x2F;documentation&#x2F;content&#x2F;multilingual&#x2F;">Multilingual sites</a>
</li>
</ul>
</li>
<li>
<span class="documentation__sidebar__title">Templates</span>
<ul>
<li class="">
<a href="https:&#x2F;&#x2F;www.getzola.org&#x2F;documentation&#x2F;templates&#x2F;overview&#x2F;">Overview</a>
</li>
<li class="">
<a href="https:&#x2F;&#x2F;www.getzola.org&#x2F;documentation&#x2F;templates&#x2F;pages-sections&#x2F;">Sections and Pages</a>
</li>
<li class="">
<a href="https:&#x2F;&#x2F;www.getzola.org&#x2F;documentation&#x2F;templates&#x2F;pagination&#x2F;">Pagination</a>
</li>
<li class="">
<a href="https:&#x2F;&#x2F;www.getzola.org&#x2F;documentation&#x2F;templates&#x2F;taxonomies&#x2F;">Taxonomies</a>
</li>
<li class="active">
<a href="https:&#x2F;&#x2F;www.getzola.org&#x2F;documentation&#x2F;templates&#x2F;feeds&#x2F;">Feeds</a>
</li>
<li class="">
<a href="https:&#x2F;&#x2F;www.getzola.org&#x2F;documentation&#x2F;templates&#x2F;sitemap&#x2F;">Sitemap</a>
</li>
<li class="">
<a href="https:&#x2F;&#x2F;www.getzola.org&#x2F;documentation&#x2F;templates&#x2F;robots&#x2F;">Robots.txt</a>
</li>
<li class="">
<a href="https:&#x2F;&#x2F;www.getzola.org&#x2F;documentation&#x2F;templates&#x2F;404&#x2F;">404 error page</a>
</li>
<li class="">
<a href="https:&#x2F;&#x2F;www.getzola.org&#x2F;documentation&#x2F;templates&#x2F;archive&#x2F;">Archive</a>
</li>
</ul>
</li>
<li>
<span class="documentation__sidebar__title">Themes</span>
<ul>
<li class="">
<a href="https:&#x2F;&#x2F;www.getzola.org&#x2F;documentation&#x2F;themes&#x2F;overview&#x2F;">Overview</a>
</li>
<li class="">
<a href="https:&#x2F;&#x2F;www.getzola.org&#x2F;documentation&#x2F;themes&#x2F;installing-and-using-themes&#x2F;">Installing &amp; using themes</a>
</li>
<li class="">
<a href="https:&#x2F;&#x2F;www.getzola.org&#x2F;documentation&#x2F;themes&#x2F;creating-a-theme&#x2F;">Creating a theme</a>
</li>
<li class="">
<a href="https:&#x2F;&#x2F;www.getzola.org&#x2F;documentation&#x2F;themes&#x2F;extending-a-theme&#x2F;">Customizing a theme</a>
</li>
</ul>
</li>
<li>
<span class="documentation__sidebar__title">Deployment</span>
<ul>
<li class="">
<a href="https:&#x2F;&#x2F;www.getzola.org&#x2F;documentation&#x2F;deployment&#x2F;overview&#x2F;">Overview</a>
</li>
<li class="">
<a href="https:&#x2F;&#x2F;www.getzola.org&#x2F;documentation&#x2F;deployment&#x2F;sourcehut&#x2F;">Sourcehut Pages</a>
</li>
<li class="">
<a href="https:&#x2F;&#x2F;www.getzola.org&#x2F;documentation&#x2F;deployment&#x2F;netlify&#x2F;">Netlify</a>
</li>
<li class="">
<a href="https:&#x2F;&#x2F;www.getzola.org&#x2F;documentation&#x2F;deployment&#x2F;github-pages&#x2F;">GitHub Pages</a>
</li>
<li class="">
<a href="https:&#x2F;&#x2F;www.getzola.org&#x2F;documentation&#x2F;deployment&#x2F;gitlab-pages&#x2F;">GitLab Pages</a>
</li>
<li class="">
<a href="https:&#x2F;&#x2F;www.getzola.org&#x2F;documentation&#x2F;deployment&#x2F;codeberg-pages&#x2F;">Codeberg Pages</a>
</li>
<li class="">
<a href="https:&#x2F;&#x2F;www.getzola.org&#x2F;documentation&#x2F;deployment&#x2F;edgio&#x2F;">Edgio</a>
</li>
<li class="">
<a href="https:&#x2F;&#x2F;www.getzola.org&#x2F;documentation&#x2F;deployment&#x2F;vercel&#x2F;">Vercel</a>
</li>
<li class="">
<a href="https:&#x2F;&#x2F;www.getzola.org&#x2F;documentation&#x2F;deployment&#x2F;zeabur&#x2F;">Zeabur</a>
</li>
<li class="">
<a href="https:&#x2F;&#x2F;www.getzola.org&#x2F;documentation&#x2F;deployment&#x2F;cloudflare-pages&#x2F;">Cloudflare Pages</a>
</li>
<li class="">
<a href="https:&#x2F;&#x2F;www.getzola.org&#x2F;documentation&#x2F;deployment&#x2F;flyio&#x2F;">Fly.io</a>
</li>
<li class="">
<a href="https:&#x2F;&#x2F;www.getzola.org&#x2F;documentation&#x2F;deployment&#x2F;aws-s3&#x2F;">AWS S3 Bucket</a>
</li>
<li class="">
<a href="https:&#x2F;&#x2F;www.getzola.org&#x2F;documentation&#x2F;deployment&#x2F;docker-image&#x2F;">Docker image</a>
</li>
</ul>
</li>
</ul>
</aside>
<div class="documentation__content">
<h1>Feeds</h1>
<p>If the site <code>config.toml</code> file sets <code>generate_feeds = true</code>, then Zola will
generate feed files for the site, named according to the <code>feed_filenames</code>
setting in <code>config.toml</code>, which defaults to <code>atom.xml</code>. Given the feed filename
<code>atom.xml</code>, the generated file will live at <code>base_url/atom.xml</code>, based upon the
<code>atom.xml</code> file in the <code>templates</code> directory, or the built-in Atom template.</p>
<p><code>feed_filenames</code> can be set to any value, but built-in templates are provided
for <code>atom.xml</code> (in the preferred Atom 1.0 format), and <code>rss.xml</code> (in the RSS
2.0 format). If you choose a different filename (e.g. <code>feed.xml</code>), you will
need to provide a template yourself.</p>
<p>In case you want to extend, or modify, the built-in templates, you can get a
copy from <a href="https://github.com/getzola/zola/tree/master/components/templates/src/builtins">the source code here</a>
and place it in the <code>templates/</code> directory with the appropriate name. You can
check the documentation for the specifications for Atom 1.0 and RSS 2.0 in
<a href="https://validator.w3.org/feed/docs/">W3C Feed Validation Service</a>.</p>
<p><strong>Only pages with a date will be available.</strong></p>
<p>The author in the feed is set as</p>
<ul>
<li>The first author in <code>authors</code> set in the
<a href="https://www.getzola.org/documentation/content/page/#front-matter">front matter</a></li>
<li>If that is not present it falls back to the <code>author</code> in the
<a href="https://www.getzola.org/documentation/getting-started/configuration/">Configuration</a></li>
<li>If that is also not preset it is set to <code>Unknown</code>.</li>
</ul>
<p>Note that <code>atom.xml</code> and <code>rss.xml</code> require different formats for specifying the
author. According to <a href="https://www.rfc-editor.org/rfc/rfc4287">RFC 4287</a> <code>atom.xml</code> requires the author's
name, for example <code>"John Doe"</code>. While according to the
<a href="https://www.rssboard.org/rss-specification#ltauthorgtSubelementOfLtitemgt">RSS 2.0 Specification</a> the email address is required, and the name
optionally included, for example <code>"lawyer@boyer.net"</code> or
<code>"lawyer@boyer.net (Lawyer Boyer)"</code>.</p>
<p>The feed template gets five variables:</p>
<ul>
<li><code>config</code>: the site config</li>
<li><code>feed_url</code>: the full url to that specific feed</li>
<li><code>last_updated</code>: the most recent <code>updated</code> or <code>date</code> field of any post</li>
<li><code>pages</code>: see <a href="https://www.getzola.org/documentation/templates/pages-sections/#page-variables">page variables</a>
for a detailed description of what this contains</li>
<li><code>lang</code>: the language code that applies to all of the pages in the feed,
if the site is multilingual, or <code>config.default_language</code> if it is not</li>
</ul>
<p>Feeds for taxonomy terms get two more variables, using types from the
<a href="https://www.getzola.org/documentation/templates/taxonomies/">taxonomies templates</a>:</p>
<ul>
<li><code>taxonomy</code>: of type <code>TaxonomyConfig</code></li>
<li><code>term</code>: of type <code>TaxonomyTerm</code>, but without <code>term.pages</code> (use <code>pages</code> instead)</li>
</ul>
<p>You can also enable separate feeds for each section by setting the
<code>generate_feeds</code> variable to true in the respective section's front matter.
Section feeds will use the same template as indicated in the <code>config.toml</code> file.
Section feeds, in addition to the five feed template variables, get the
<code>section</code> variable from the <a href="https://www.getzola.org/documentation/templates/pages-sections/">section
template</a>.</p>
<p>Enable feed autodiscovery allows feed readers and browsers to notify user about a RSS or Atom feed available on your web site. So it is easier for user to subscribe.
As an example this is how it looks like using <a href="https://en.wikipedia.org/wiki/Mozilla_Firefox">Firefox</a> <a href="https://addons.mozilla.org/en-US/firefox/addon/livemarks/?src=search">Livemarks</a> addon.</p>
<p><img src="https://www.getzola.org/documentation/templates/feeds/rss_feed.png" alt="RSS feed autodiscovery example." /></p>
<p>You can enable posts autodiscovery modifying your blog <code>base.html</code> template adding the following code in between the <code>&lt;head&gt;</code> tags.</p>
<pre data-lang="html" style="background-color:#383838;color:#e6e1dc;" class="language-html "><code class="language-html" data-lang="html"><span>{% block rss %}
</span><span> &lt;</span><span style="color:#e8bf6a;">link </span><span style="color:#86c20e;">rel=</span><span>&quot;</span><span style="color:#c1be91;">alternate</span><span>&quot; </span><span style="color:#86c20e;">type=</span><span>&quot;</span><span style="color:#c1be91;">application/rss+xml</span><span>&quot; </span><span style="color:#86c20e;">title=</span><span>&quot;</span><span style="color:#c1be91;">RSS</span><span>&quot; </span><span style="color:#86c20e;">href=</span><span>&quot;</span><span style="color:#c1be91;">{{ get_url(path=</span><span>&quot;</span><span style="color:#86c20e;">rss.xml</span><span style="background-color:#b90622;color:#f8f8f0;">&quot;</span><span style="color:#86c20e;">, trailing_slash=</span><span style="color:#a5c261;">false) </span><span style="color:#86c20e;">}}</span><span style="background-color:#b90622;color:#f8f8f0;">&quot;</span><span>&gt;
</span><span>{% endblock %}
</span></code></pre>
<p>You can as well use an Atom feed using <code>type="application/atom+xml"</code> and <code>path="atom.xml"</code>.</p>
<p>All pages on your site will refer to your post feed.</p>
<p>In order to enable the tag feeds as well, you can overload the <code>block rss</code> using the following code in your <code>tags/single.html</code> template.</p>
<pre data-lang="html" style="background-color:#383838;color:#e6e1dc;" class="language-html "><code class="language-html" data-lang="html"><span>{% block rss %}
</span><span> {% set rss_path = &quot;tags/&quot; ~ term.name ~ &quot;/rss.xml&quot; %}
</span><span> &lt;</span><span style="color:#e8bf6a;">link </span><span style="color:#86c20e;">rel=</span><span>&quot;</span><span style="color:#c1be91;">alternate</span><span>&quot; </span><span style="color:#86c20e;">type=</span><span>&quot;</span><span style="color:#c1be91;">application/rss+xml</span><span>&quot; </span><span style="color:#86c20e;">title=</span><span>&quot;</span><span style="color:#c1be91;">RSS</span><span>&quot; </span><span style="color:#86c20e;">href=</span><span>&quot;</span><span style="color:#c1be91;">{{/* get_url(path=rss_path, trailing_slash=false) */}}</span><span>&quot;&gt;
</span><span>{% endblock rss %}
</span></code></pre>
<p>Each tag page will refer to it's dedicated feed.</p>
</div>
</div>
</div>
<footer>
©2017-2024 — <a class="white" href="https://www.vincentprouillet.com">Vincent Prouillet</a> and <a class="white" href="https://github.com/getzola/zola/graphs/contributors">contributors</a>
</footer>
<script type="text/javascript" src="https://www.getzola.org/elasticlunr.min.js"></script>
<script type="text/javascript" src="https://www.getzola.org/search.js"></script>
</body>
</html>