如何在 Hugo 中修改站点地图 URL?

How can I modify the sitemap URL in Hugo?

默认情况下,Hugo 在 /sitemap.xml 公开其站点地图;由于我的代理设置,我需要在 /static-content/sitemap.xml.

公开它

我最初的方法是利用 set the sitemap URL front mater 的能力;但是,我无法弄清楚如何在内容目录中创建一个文件,该文件将在呈现站点地图时被拾取。

您可以在 Hugo 配置文件中配置站点地图文件名。我刚刚在 config.yaml.

中尝试了以下内容
sitemap:
  filename: static-content/sitemap.xml

而且成功了!这记录在 https://gohugo.io/templates/sitemap-template/