rrsshugoblogdown

Change blogdown rss template


I know there are many similar questions, but none so far worked for me, please read the question before flagging as duplicate.

I created a site with the Rstudio addins that the blogdown package provides, added two pages with categories. The rss feeds for the categories get generated almost correctly but I did not find a way to edit the template. For the categories "R" and "caving" the title of the rss feed is "Rs on ..." and "Cavings on ..." which does not make sense. I want to change it to "R posts on ..." or "Posts in R on ..." or something similar.

Can I change this in the config or do I need to edit the rss templates?

If I need to edit the rss templates: where do I put them, I tired /layouts/rss.xml, /layouts/categories.rss.xml, /layouts/r/rss.xml none of them were picked up correctly (when serving the site with blogdown::serve_site()).


The folder structure looks like this:

content/
├── about.md
├── caving
│   └── 2024-01-27-example-caving-post
│       └── index.md
├── misc
├── R
│   └── 2024-01-27-adventures-in-shinylive
│       └── index.md
└── stats

The post in R:

---
title: Adventures in Shinylive
author: Tobias Fellinger
date: '2024-01-27'
slug: adventures-in-shinylive
categories:
  - R
tags:
  - R
  - shiny
  - web-r
  - shinylive
---

This will be a blogpost about porting a shiny app to shinylive.

The post in caving:

---
title: example caving post
author: Tobias Fellinger
date: '2024-01-27'
slug: example-caving-post
categories:
  - caving
tags:
  - caving
---


this is a test

and this is the config.yaml:

baseurl: /
languageCode: en-US
title: "Tobias Fellinger's Blog"
theme: hugo-lithium
googleAnalytics: ''
disqusShortname: ''
ignoreFiles:
  - \.Rmd$
  - \.Rmarkdown$
  - _cache$
permalinks:
  post: /:year/:month/:day/:slug/
menu:
  main:
    - name: About
      url: /about/
    - name: R
      url: /r/
    - name: Caving
      url: /caving/
params:
  MathJaxCDN: //cdnjs.cloudflare.com/ajax/libs
  MathJaxVersion: 2.7.5
  description: A website built through Hugo and blogdown.
  favicon: favicon.ico
  highlightjsCDN: //cdnjs.cloudflare.com/ajax/libs
  highlightjsLang:
    - r
    - yaml
  highlightjsTheme: github
  highlightjsVersion: 9.12.0
  logo:
    alt: Logo
    height: 50
    url: logo.png
    width: 50
markup:
  defaultMarkdownHandler: goldmark
  goldmark:
    renderer:
      unsafe: yes
  highlight:
    codeFences: no

Besides this everything is the defaults as created by blogdown_1.18.

To access the rss feed I used blogdown::serve_site() and then visited http://localhost:4321/caving/index.xml or http://localhost:4321/r/index.xml


Solution

  • So there were two misconceptions on how hugo works.

    1. template lookup: the templates are not used per category but by section, a section is everything that has a top-level directory under content or an _index.md file in the folder 1. To override the rss template one has to put the custom template in layouts/section/section.rss.xml to override the template for all sections or in layouts/section/<section-name>.rss.xml to override just for the section <section-name> 2.
    2. this still won't help with hugo adding s to the end of your section title. This can be done by adding the line pluralizeListTitles: no to config.yaml 3.

    In this case I did not have to override any templates but just change the config options to not pluralize list titles. Pluralizing list titles being the default is absolutely counterintuitive to me and I more or less found the option by chance on searching on how to change the rss templates.