published on 05.08.2020

This post will be very short and precise. In Jekyll, we had to create an .xml file using liquid templates to tell Jekyll that we want an rss.xml or similarly sitemap.xml. Luckily, Hugo creates these files for us under the hood. You can check them by going to /index.xml and /sitemap.xml pages in your Hugo website. Hugo even creates “index.xml” for sections and taxonomies.

However, you may want to overwrite the default RSS template because it’ll include only the pages directly under your root (/content) folder and it’ll include pages like about.md. To overwrite the default RSS template, you need to copy the original template into /layouts/_default/and name it as index.rss.xml.

Then you need to, change how it loops over {{ range $pages }}. This is how I set $pages to include all sub-folders (sections as Hugo called them) and exclude ordinary pages like “about page”.

{{- $pages := where $.Site.RegularPages ".Type" "!=" "ordinary" -}}

Done!

One last thing, if you name the file as /layouts/_default/rss.xml, then it will affect all RSS files including section RSS, taxonomy RSS. For example, let’s say I have a section called “blog” then Hugo will generate an RSS feed at /blog/index.xml. This is the default behavior. If we name the file as rss.xml instead of index.rss.xml Hugo will apply our template not only on /index.xml but also /blog/index.xml which is not what I want. See, RSS Template Lookup Order from Hugo docs.

You are reading the 5th of 19 episodes in Hugo.
Published on 05.08.2020 by Mert Bakır with commit db8d56a.
hugo
#hugo #rss #static-site
Next episode:
Sitemap & Robots & NoIndex NoFollow
published on 06.08.2020

Search engine bots or crawlers, use two files to crawl a website more intelligently. These are robots.txt and sitemap.xml. A robots.txt file tells search engine crawlers which pages or files the crawler can or can’t request from the site. This is used mainly to avoid overloading your site with …

published on 21.08.2020

Math typesetting, or rendering LaTeX, in Hugo is not a hard task. We have two popular alternatives. First one is mathjax, I was using it before with jekyll. The other popular library for math typesetting is KaTeX. Since it’s faster, this time I’ll go with KaTeX. Implementing these …

published on 22.08.2020

Tags in Hugo is a default taxonomy and we don’t need any special configuration to use tags. We just enter the tags in the post’s front-matter. This can be YAML, TOML, or JSON. I’m using the YAML format, just a personal preference. […] tags:["hugo","tags"]In …

published on 10.07.2022

Previously, I’ve published a blog post about deploying static content on heroku with basic authentication. The main purpose was to get basic auth for a freely hosted static website. In that post, we hosted the source code on GitLab and configured a CI/CD pipeline to render the static content …

published on 28.05.2022

Each git commit has a field called Author which consists ‘user.name’ and ‘user.email’. We usually set these variables once, after installing git, with git config --global so that each repo gets the variables from the global definition. We can also set them locally for a …

published on 25.05.2022

In this post, I’ll first walk through hosting static content with basic authentication. Then, we’ll look into deploying to Heroku using GitLab Pipelines, more specifically deploying a certain sub-directory within the project instead of pushing the whole project. Also, I’ll share …

published on 17.04.2022
edited on 15.07.2022

Önceki bölümde, markdown formatını LaTeX formatına dönüştürmek için kullanılan Pandoc yazılımından bahsetmiştik. Şimdi konuyu bir adım daha ileri taşıyıp ve bookdown’a geçiyoruz. Bookdown; Rmarkdown kullanarak teknik dökümanlar, kitaplar yazabilmemizi sağlayan, Yihui Xie tarafından yazılmış …

published on 10.04.2022

I’ve been using WSL-2 on Windows for over a year. It’s very useful because some Python packages are just a headache to install on Windows. Also, docker. It’s just better on Linux. Yet, WSL-2 can also be problematic. I remember trying a dual-boot setup when things just went way too …

published on 03.03.2022

In this post, I’ll share how to install geopandas and some other gis related packages on Windows. If you are on Mac or Linux you can probably just pip install those without any issue. I usually had to do a google search every time I wanted to install these packages on Windows environment. Of …