1

I have my website with its sitemap submitted to the Google Search Console, the whole shebang. Unfortunately, my indexing isn't going so well. I've narrowed down the problem to make my URL cleaner. I've added a little bit of code in my .htaccess file. So instead of having an URL like https://example.com/contact.html you'd get https://example.com/contact. The problem is, now my sitemap thinks it's two separate URLs, which makes the Search Console think there are duplicates.

My question thus is: which URL should I remove from my sitemap? Technically, the https://example.com/contact is the one "in use" but since the other one is the "real" URL, I'm worried it could cause problems if I remove it.

1 Answer 1

3

Your XML sitemap should contain the version of the URL that you want to have indexed. If you prefer the new clean URLs that don't end in .html and they are the ones that are in use in your site, those URLs should go in your sitemap.

The old .html URLs should be removed from your sitemap. Your sitemap should not contain duplicate content.

Sitemaps don't usually help much with SEO, but one of the things they can do is tell Google which URLs you prefer. When you choose a version of the URL to put in your XML sitemap, Google will take that as a canonicalization signal and choose to index that version of the URL.

That being said, I wouldn't solely rely on XML sitemaps for canonicalization. I would recommend putting canonical meta tags on all your pages that remove the .html from the URLs. Even better would be redirecting the .html URLs to the new clean URLs.

3
  • Hi! Thank you for your answer! This helps a lot. Unfortunately, I can't apply your last advice. I only have HTML pages in my website files manager, and I added a bit of code in my .htaccess file so it would look like there is no .html extension in my url. But I can't redirect, since there isn't anything to redirect to, and I can't add the tags to my html files since it would indicate that these are the ones I want indexed, isn't it?
    – camille
    Oct 14, 2023 at 13:44
  • You can add canonical tags to your .html files. The canonical would point to the URL without the .html extension. Both your preferred URL and the one ending in .html would tell Google to use the one without the extension. Oct 14, 2023 at 17:45
  • It should also be possible to remove the .html with a redirect. This answer on Stack Overflow has the rule to do it. It is the NC,L,R rule. My only improvement on that would be change it to NC,L,R=301 after you confirm it is working so the redirects are permanent. Oct 14, 2023 at 17:48

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.