Hugo Rss

发布于26.09.2023

Categories: 博客  Tags: hugo rss 博客 

本文简介如何为 hugo 博客添加 rss 。

hugo 具有自带的rss 功能1,在 hugo.toml 中添加如下代码,启用hugo的rss生成。

[outputs]
    home = ['html', 'rss']
    section = ['html', 'rss']
    taxonomy = ['html']
    term = ['html']

# 以下为版权声明与作者信息,请自行更改对应字符串
copyright = "©版权信息"
languageCode = "zh-cn"
[Author]
name = "YOUR_NAME"
email = "me@example.com"

而后在layouts/partials/header.html<head> 标签中添加如下字段:

  <link rel="alternate"
          type="application/rss+xml"
          href="{{.Site.BaseURL }}/index.xml"
          title="{{ .Site.Title }}">

此时浏览器的rss插件即可找到rss订阅链接。

对于默认生成的rss,其只生成摘要,而且默认监视所有页面的变化,如果需要生成全部内容的rss,或者修改为监视 content\posts下文章的变化,请参考此处2

如果对修改内容不感兴趣,只需要修改后的代码,请查看我的代码,如果需要恢复原样,请删除rss.xml3


  1. https://gohugo.io/templates/rss/ ↩︎

  2. https://digitaldrummerj.me/hugo-create-rss-feed/ ↩︎

  3. https://github.com/gohugoio/hugo/blob/master/tpl/tplimpl/embedded/templates/_default/rss.xml ↩︎