hugo-theme-more-contentful/exampleSite/content/en/articles/rss-atom-and-json-feed-support.adoc
Gabriel Arazas 2f06fd7861 Initial release
All of the changes should be documented in the changelog.
2020-11-03 00:55:18 +08:00

2.5 KiB
Raw Blame History


title: "RSS, Atom, and JSON Feed Support" date: 2019-09-04T17:22:44+08:00 author: - name: "John Doe" - name: "Jane Doe" aliases: - "/feeds/" categories: - "guide" tags: - "this is a test tag" - "tag2" ---

RSS, Atom, and JSON Feed Support

John Dodo <johndodo@example.com> 2019-09-04 :stem: latexmath

Web feeds are one of the most common ways for a visitor to keep up with someone who creates content. Nowadays, most social media has that feature such as the subscribing YouTube channels, following Twitter accounts, and watching Deviantart artists. Outside of those, we have simpler things like RSS and JSON feeds where they are just plain text files describing the content.

The Contentful theme doesnt have a web feed export but we can have it with theme components. For this demo, well use the web feed component created by foo-dogsquared.

If youre settling with this option, heres an example template for installing the web feed module and exporting all of the feed formats all in one fell swoop.

[[module.imports]]
    path = "github.com/foo-dogsquared/hugo-web-feeds"

# Visit the following for more information:
# https://gohugo.io/templates/output-formats

# Defining the media type of the output formats
# For JSON format, it doesn't need to be since it's already built-in into Hugo
[mediaTypes]
    [mediaTypes."application/atom+xml"]
        suffixes = ["atom", "atom.xml"] # You can remove the "atom.xml" if you want

    # Redefining RSS media type for the additional suffix
    [mediaTypes."application/rss+xml"]
        suffixes = ["rss", "rss.xml"] # You can remove the "rss.xml" if you want

    [mediaTypes."application/feed+json"]
        suffixes = ["json"] # You can remove the "rss.xml" if you want


# Including all of the feed output formats in the build
[outputFormats]
    [outputFormats.Rss]
        mediaType = "application/rss+xml"
        baseName = "feed"

    [outputFormats.Atom]
        mediaType = "application/atom+xml"
        baseName = "feed"

    [outputFormats.Json]
        mediaType = "application/feed+json"
        baseName = "feed"


# Indicating what output formats shall be included
# for the following kinds
[outputs]
    # .Site.BaseURL/index.* is available
    home = ["HTML", "JSON", "RSS", "ATOM"]

    # .Site.BaseURL/$section/index.* is available
    section = ["HTML", "JSON", "RSS", "ATOM"]