1

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

2 Answers 2

0

your rss feed template should be in layouts/_defaults/rss.xml if its not there, just create the file.

If you want to create different rss feeds for each category then make a file for each category. For example, for the category "r" you can create layouts/category/r.xml

more information: https://gohugo.io/templates/rss/

2
  • I copied the default rss template in both paths you suggested and changed the feed title to see if it changes and the template was not used in either path. Did you use blogdown or just plain hugo? This question was specifically about blogdown.
    – snaut
    Commented Feb 6 at 16:25
  • layouts/_default/rss.xml (singular default not defaults) works. The path for the categories is not picked up when rendering.
    – snaut
    Commented Feb 6 at 16:50
0

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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.