You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 

3.5 KiB

+++ title = "Web Feeds" description = "Share RSS feeds with full-content and optional enclosures." categories = ["search"] tags = ["metadata", "robots", "SEO"] features = ["snippets", "related content", "code highlighter"] copyright owner = "Josh Habdas" date = "2019" license = "agpl-3.0-or-later" +++

After Dark provides RSS web feeds conforming with the {{< external "https://cyber.harvard.edu/rss/rss.html" "RSS 2.0 Specification" />}} and enhanced semantically using the following custom extensions:

Feeds are generated automatically on a per-section basis, in addition to a consolidated site-wide feed combining content from across the site:

Add multimedia attachments to pages and posts using RSS enclosures. Enclosures will output automatically to feeds when supplied. To supply an enclosure create a {{< external "https://gohugo.io/content-management/page-bundles/" "Page Bundle" />}} as described in [Post Images]({{< relref "post-images" >}}) and shown here for a blog post:

├── archetypes
├── content
│   └── post
│       └── backup-restore-macos-mojave
│           ├── assets
│           │   └── macos_v10.14.3-upgrade-fail.mp4
│           ├── images
│           └── index.md
├── layouts

Then reference the resource from front matter as shown here:

[[resources]]
  src = "assets/macos_v10.14.3-upgrade-fail.mp4"
  name = "enclosure"
  title = "Software Update Malfunction: Mojave 10.14.3"
  [resources.params]
    length = "3705578"

{{% hackcss-alert type="info" %}}Note: Length is the number of bytes in the file and required by RSS 2.0 spec.{{% /hackcss-alert %}}

{{% hackcss-alert type="success" %}}Tip: From a terminal get length using wc -c < /path/to/file.{{% /hackcss-alert %}}

Enclosures may be output to page content by creating a custom shortcode or using a [Custom Layout]({{< relref "custom-layouts" >}}) with content like:

{{ with .Resources.GetMatch "enclosure" }}{{ if .Params.length }}
  <svg id="i-paperclip" viewBox="0 0 32 32" width="16" height="16" fill="none" stroke="var(--accent-color)" stroke-linecap="round" stroke-linejoin="round" stroke-width="2">
    <path d="M10 9 L10 24 C10 28 13 30 16 30 19 30 22 28 22 24 L22 6 C22 3 20 2 18 2 16 2 14 3 14 6 L14 23 C14 24 15 25 16 25 17 25 18 24 18 23 L18 9" />
  </svg>
  <a href="{{ .Permalink }}" title="{{ with .Title }}{{ . }} {{ end }}[{{ .Params.length }} byte {{ .MediaType }}]">Enclosure</a>
{{ end }}{{ end }}

Use the {{< external "https://validator.w3.org/feed/" "W3C Feed Validation Service" />}} to validate your feed. For help creating custom shortcodes see {{< external "https://gohugo.io/templates/shortcode-templates/#create-custom-shortcodes" "Create Your Own Shortcodes" />}} on the Hugo docs site.

See {{< external "https://gohugo.io/templates/rss/" "RSS Templates" />}} in Hugo for additional information.