rxdn / mdbook-sitemap-generator

Utility to generate a sitemap.xml file for an mdbook project
MIT License
7 stars 3 forks source link

Incorrrect sitemap? #2

Open joepio opened 12 months ago

joepio commented 12 months ago

Hi there! I just created a sitemap, hosted it and submitted it to google, but got a couple of errors:

Screenshot 2023-12-04 at 17 50 27
Sitemap can be read, but has errors
Invalid XML tag
96 instances
This tag was not recognised. Please fix it and resubmit.
Examples
Line 1
Parent tag:
urlset
Tag:
urls
Line 1
Parent tag:
urlset
Tag:
urls
Line 1
Parent tag:
urlset
Tag:
urls
Missing XML tag
1 instance
This required tag is missing. Please add it and resubmit.
Examples
Line 1
Parent tag:
urlset
Tag:
url
Incorrect namespace
1 instance
Your Sitemap or Sitemap index file does not properly declare the namespace.
Examples
Line 1
Tag:
urlset
john-cd commented 10 months ago

I had to postprocess with

sed -i -e 's///g' -e 's/<\/urls>/<\/url>/g' book/sitemap.xml

micahsnyder commented 10 months ago

I had the same issue.

abgelehnt commented 9 months ago

I used several commands to resolve errors:

sed -i -e 's/urls>/url>/g' book/sitemap.xml # not recognised tags
sed -i -e 's/xlmns/xmlns/g' book/sitemap.xml # error namespaces 
SichangHe commented 6 months ago

Portable version (works on both Linux and macOS).

mdbook-sitemap-generator -d <DOMAIN> \
    | awk '{gsub(/urls>/, "url>"); gsub(/xlmns/, "xmlns"); print}' \
        > <OUTPUT_DIR>/sitemap.xml
SichangHe commented 3 months ago

Uh. This is pointless. Just use a generic sitemap generator on the generated site.

bartvanderwal commented 1 month ago

Yes indeed. Piping through awk also fixed the errors that Google Search Console was giving me. I was using the latest version 0.2.0 available in cargo.

But this is just a work-around. The generated <urls> tags in the sitemap.xml should all be <url>. Isn't that a relatively simple fix? 😅

bartvanderwal commented 1 month ago

Ah yes, a pull request with a fix was already submitted by someone else: https://github.com/rxdn/mdbook-sitemap-generator/pull/3

Could you please accept? 😄