gohugoio / hugo

The world’s fastest framework for building websites.
https://gohugo.io
Apache License 2.0
75.39k stars 7.49k forks source link

Expose `.SitemapAbsURL` to robots.txt #12197

Closed septs closed 7 months ago

septs commented 7 months ago

Motivation

expose .SitemapAbsURL, can simplify robots.txt provide sitemap absolute url complex

especially multi-site, multi-language

Current Status

Expected

User-agent: *
Sitemap: {{ .SitemapAbsURL }}
{{- range .Sites }}
Sitemap: {{ .SitemapAbsURL }}
{{- end }}

References

https://github.com/gohugoio/hugo/blob/b1de03f398620eb97e005ae01e1955627475b7c9/hugolib/site.go#L543-L551

jmooring commented 7 months ago

Using SitemapAbsURL[^1] in a robots.txt file would work for:

But, as implemented in v0.111.3, it would fail for multilingual, single-host sites. In that case, the robots.txt file should point to the sitemap index, not a sitemap.

[^1]: This was exposed to the templates in v0.111.3 and earlier, removed in v0.112.0.

I'm closing this in favor of https://github.com/gohugoio/hugo/issues/4678.

github-actions[bot] commented 7 months ago

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.