Sitemap lastmod errors for tags and categories

Hello @everyone
My sitemap has some errors for some tags and categories, but not for all.
The lastmod date for these is 0001-01-01.
I’m using the BlogRa theme: GitHub - rafed/BlogRa: The Ultimate Tech Blogging Hugo Theme

Not a big problem but without errors is better of course.
Thanks in advance

Nothing one could do her with just stating it does not work… see Requesting Help

May you get a faster and accurate answer if you use their github issue tracker

I didn’t says it like you say I did.
Google Console says there is an error at line so and so (e.g. line 392).
At these lines the lastmod date is 0001-01-01 which makes Google say this is not correct (date).
For the code I linked to the repo.

Mmh.

Error in line 392 which error, which file

You shared the theme repo not yours.

I still think you should elaborate your post

In the sitemap of course. Sorry if that wasn’t clear.
And line 392 is a lastmod date with value 0001-01-01 - as already said.
Google Console error says date is wrong.
I already said that.

I’m using this theme vanilla.

And it’s all not a big problem. I thought it could just even be a hugo bug to consider, or something new which causes that problems et cetera.

BTW sorry for my bad language abilities.

let’s see how far we can get

hugo new site bla
cd bla
git init
git submodule add https://github.com/rafed/BlogRa.git themes/BlogRa
echo "theme = 'BlogRa'" >> hugo.toml
hugo
cat public/sitemap.xml
public/sitemap.xml
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
  
      
      
      
	  <url>
	    <loc>https://example.org/categories/</loc>
	    <lastmod>0001-01-01</lastmod>
        

        
	  </url>
	  
  
      
      
      
	  <url>
	    <loc>https://example.org/</loc>
	    <lastmod>0001-01-01</lastmod>
        

        
	  </url>
	  
  
      
      
      
	  <url>
	    <loc>https://example.org/tags/</loc>
	    <lastmod>0001-01-01</lastmod>
        

        
	  </url>
	  
  
</urlset>

No line 392 :wink: but your invalid date for all stuff listed and not for some as I suppose for your content

check out: themes\BlogRa\layouts\sitemap.xml

The templates uses .Lastmod (line 8) of the listed pages and this is unset.

see: Lastmod | Hugo for details about the lastmod attribute

so not a bug here, just a reference to an set value.

Estimation:

you have some pages that do not have a Frontmatter attribute lastmod set

So it depends on the theme and your content!

Thank you very much for the insights.
The problem is that is only for categories and tags.
The posts seem to be fine without the lastmod attribute.
I don’t have an idea how to set lastmod tor e.g. tags.

Maybe I have to purge these tags, use lastmod on every post and re-add these tags later.
But this can’t be a proper approach.

But thank you very much so far.

You could try to add an _index.md files to /content/tags containing just frontmatter

+++
lastmod = 2024-07-12
+++

Works in the bare setup. Dunno if that has any negative impact with your content. Just give it a try

Other options:

  • adress to the theme author to improve the theme
  • customize the template to use fe now if the attribute is not set
  • enable gitinfo in config
1 Like

Hugo’s embedded sitemap template writes a lastmod tag only if the lastmod is not zero.

Your theme’s sitemap template doesn’t check for a zero date.

Either modify the template accordingly or raise an issue with the theme author.

1 Like