Hi guys,
I want to create my custom sitemap. I didn’t add any lastmod but hugo adds it automatically…
How can I get rid of this?
Hi guys,
I want to create my custom sitemap. I didn’t add any lastmod but hugo adds it automatically…
How can I get rid of this?
Show a repo with the template you are editing.
{{ printf "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" | safeHTML }}
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"
xmlns:xhtml="http://www.w3.org/1999/xhtml">
{{ range .Data.Pages }}<url><loc>{{ .Permalink }}</loc></url>{{ end }}
</urlset>
I didn’t write any lastmod line in it. But still it’s being added in the sitemap…
i can’t expose my repo yet
Then you have to reproduce the error in a repo and share it. Sharing snippets of template alone isn’t going to debug this.
i just find it weird that it adds lastmod to my sitemap automatically. the date from my publishDate is being used in all my .md posts
#support is not for fielding your feelings about how Hugo works. You share your project code and get fixes.
Hugo has a built-in Sitemap template, but if you want to get rid of lastmod from sitemap.xml then copy and paste below sitemap.xml template in layouts/_default/sitemap.xml
location:-
{{ printf "<?xml version=\"1.0\" encoding=\"utf-8\" standalone=\"yes\"?>" | safeHTML }}
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"
xmlns:xhtml="http://www.w3.org/1999/xhtml">
{{ range .Data.Pages }}
<url>
<loc>{{ .Permalink }}</loc>{{ with .Sitemap.ChangeFreq }}
<changefreq>{{ . }}</changefreq>{{ end }}{{ if ge .Sitemap.Priority 0.0 }}
<priority>{{ .Sitemap.Priority }}</priority>{{ end }}{{ if .IsTranslated }}{{ range .Translations }}
<xhtml:link
rel="alternate"
hreflang="{{ .Language.Lang }}"
href="{{ .Permalink }}"
/>{{ end }}
<xhtml:link
rel="alternate"
hreflang="{{ .Language.Lang }}"
href="{{ .Permalink }}"
/>{{ end }}
</url>
{{ end }}
</urlset>
Moreover if need more details on how to disable or further customize sitemap.xml for Hugo website then follow this link:-
thank you so much!!!
i had my sitemap.xml in the layouts directory instead of the layouts/_default/ directory
handy website. i didn’t know about the sitemap_ignore: true
in .md files. learned something new
[Edited] Hugo documentation says, we can add sitemap.xml in either layouts
or layouts/_default
directory. But as mentioned by @short, it works only when we place in layouts/_default
directory.
Please note that sitemap_ignore: true
is a custom parameter and do not come out of the box in hugo front-matter. You can add any number of custom parameters in your page front-matter say my_custom_parameter: random_value
. Once you create parameters, you can access those custom parameters using page variables .Params.my_custom_parameter
in hugo partials or sitemap.xml template.
if i have sitemap.xml in layouts instead of layouts/_default it adds the lastmod automatically… even if it’s not in my sitemap template
This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.