I have a production website running, and while adding it in Google Search Console it reports to me that the URL’s are invalid.
Has anyone else run into this?
I have a production website running, and while adding it in Google Search Console it reports to me that the URL’s are invalid.
Has anyone else run into this?
Mine has been working like a charm for a few Hugo versions now. Can you share more details?
The error messages from Google are pretty vague, but this is what is displayed:
See the guidelines at Requesting Help and post links to your source and site, so we can actually check and see if the sitemap.xml
is valid.
Discussion in these forums are specific to Hugo, but you haven’t asked a Hugo question. Please search elsewhere for debugging sitemaps and search engines. If you suspect the sitemap template is incorrect, please say so and provide context.
Discussion in these forums are specific to Hugo, but you haven’t asked a Hugo question. Please search elsewhere for debugging sitemaps and search engines. If you suspect the sitemap template is incorrect, please say so and provide context.
I’m using the default template, that is why I’m asking. Maybe someone else has run into the same problem. I wouldn’t ask otherwise.
Gist for the Hugo produced sitemap.xml:
Production site:
https://proximoconcurso.com.br
Hugo Version:
0.34 on Netlify
Source repo is private
Please state the error reporting your sitemap.xml
is invalid. Your screenshot does not include an error, nor refers to the sitemap.
Listen, I get that you think it has to do with the template in Hugo. But you haven’t explained why you think that, except you got some unrelated errors in a sitemap monitoring service. There isn’t anything we can do. To figure this out we need to see what the errors are, as well as see if it changes over time; it is possible some part of the internet had a hiccup and Google didn’t read your sitemap correctly today.
So if you want help, go back and figure these things out, and then let us know where you are stumped.
If the errors outputted by Google said more than:
“There is an error with the URL’s in your sitemap”
I would have gladly tried research more.
But whatever, I’ll research more and if I find a solution I’ll post it here.
The screenshot is from Google Search Console and it is the only information that is outputted when submitting the sitemap.xml for indexing.
Ok…
As defined in the sitemap.org documentation for :
URL of the page. This URL must begin with the protocol (such as http) and end with a trailing slash, if your web server requires it. This value must be less than 2,048 characters.
This means that you have to set baseURL
to your actual website address. This doesn’t seem ideal if you run it locally and for staging and so on. I guess one has to set environment variables for this.
I change this and pushed it to Netlify, resubmitted the sitemap and now it works.
I need to look at this again. @maiki
If I leave baseURL = “/” like this, Hugo/Netlify is able to detect and serve proper URL’s on the front i.e.; root.tld/path/to/content, and Google Search Console approves the sitemap for indexing.
However, if I set baseURL = “https://root.tld”, it sends me to the production site when running locally + asset urls are linked to the production site.
Shouldn’t sitemap.xml also be able to reflect this change so that it produces the correct url according to the https://www.sitemaps.org/protocol.html definition?
The above is not a valid baseURL. It may work in some cases, but the behaviour is in general undefined and unsupported.
Okay,
What is the recommended approach to get the baseURL to change automatically between dev and production?
It is to:
hugo server
(dev)hugo server -b http://somehost
– but then you probably also want to set the --bind
flag to the correct network interface.Sorry to revive an old thread @bep but I am curious how this best practice is intended to work on services like ours @ Netlify. Our deploy previews have URL’s like https://some-uuid–sitename.netlify.com, where the some-uuid portion is generated separately for each deploy after build, so you cannot meaningfully set a valid (using https://host/) BaseURL during build. So, we advise people to use BaseURL=/
since that does always “work” in terms of the deploy linking to its own resources rather than the production resources at the “real” BaseURL.
I suppose they could use different contexts to say "set BaseURL=/
for deploy previews and branch deploys and BaseURL=https://realhostname.com
in production…
But could you do it without mentioning my name … I get plenty of notifications as is.
Check this Hugo Boilerplate made for Forestry:
When I had this issue it was solved by using the netlify variable DEPLOY_PRIME_URL
Relevant issue: https://github.com/indigotree/atlas/issues/38
great, thanks for sharing that!
custom your own sitemap template, then set a variable to your domain name in config.toml.