1

When you host a webpage, e.g., https://mydomain.example and .htaccess already takes care of the rewrite from www to without www and from http to https and it is also rewriting with RewriteRule ^$ https://mydomain.example/en/page1.html [R=301,L] to https://mydomain.example/en/page1.html (this file obviously holds the actual HTML code) and you have also other pages https://mydomain.example/en/page2.html , https://mydomain.example/en/page3.html etc. and a similar set of pages for another language https://mydomain.example/de/page1.html (with just the same content in e.g. german language), https://mydomain.example/de/page2.html , https://mydomain.example/de/page3.html etc.

then Google gives some advice in Tell Google about localized versions of your page.

I did that, but I did not figure out whether I should keep https://mydomain.example and / or https://mydomain.example/en/page1.html in my sitemap.

Now the incoming external backlinks all point to https://mydomain.example. This is the reason why I put <link rel="canonical" href="https://mydomain.example"> in the header of https://mydomain.example/en/page1.html

The google search console indexed https://mydomain.example correctly and put https://mydomain.example/en/page1.html into the not indexed category due to Duplicate without user-selected canonical. It has meanwhile also disappeared from there.

Only recently google chrome lighthouse has added a SEO error for my setup "Document does not have a valid rel=canonicalPoints to the domain's root URL (the homepage), instead of an equivalent page of content".

Should https://mydomain.example and https://mydomain.example/en/page1.html both be in my sitemap?

Also, should I

a.) change the setup to make https://mydomain.example/en/page1.html my canoncial page? or

b.) to make https://mydomain.example/en/ my canonical startup and work with a DirectoryIndex to point to page1.html ? or

c.) leave https://mydomain.example as the canonical page since the incoming links go there?

Please note that I found a relevant answer to my question (see below), but it is very old and the accepted answer was never upvoted, so I am unsure if it (still) applies:

https://stackoverflow.com/questions/27963185/which-url-should-be-in-sitemap-xml-when-redirecting-request

Edit: Trying to make my question more clear I made substantial edit. Sorry for any invonvenience caused.

0

1 Answer 1

2

Your sitemap should contain the URLs that you want search engines to index. It should not contain any URLs that:

  1. Redirect
  2. Are not canonical

Google says:

List only canonical URLs in your sitemaps. If you have multiple versions of a page, list in the sitemap only the one you prefer to appear in search results. If you have multiple versions of your site (for example, www and non-www), decide which is your preferred site, and put the sitemap there, and add rel=canonical or redirects on the other site.

Therefore the following URLs should be included in your sitemap:

  • https://mydomain.example/en/home.html
  • https://mydomain.example/de/home.html
  • https://mydomain.example/es/home.html

And the following URLs should be omitted from your sitemap:

  • https://mydomain.example/
  • http://mydomain.example/
  • https://www.mydomain.example/

As an aside, I would recommend removing home.html from your URLs. https://mydomain.example/en/ is a cleaner, simpler, more user-friendly URL compared to https://mydomain.example/en/home.html. Default documents like index.html and home.html should never appear in URLs to the user.

4
  • Thanks for the useful reply. Until now I had mydomain.example as the canonical url. And all my incoming external backlinks point to there. Is it still recommended for me to now change the canonical tag to point to mydomain.example/en/home.html ? (there might be a seo loss?) And so it can be that the canonical url is never displayed to the user? (Sorry it seems I still have to learn a few things here). So your recommendation is to use DirectoryIndex to display the home.html content?
    – Peter206
    Jan 23, 2023 at 13:41
  • If you are adding languages to your site, you need to have the separate languages on separate URLs for SEO. It is possible to have the English version on / and the Spanish version on /es/. If you moved the English version to /en/ it might have a short term SEO drop, but it would recover and not be a long term problem. You'd want to have a language chooser of some sort on the / URL. Jan 23, 2023 at 13:50
  • You can use DirectoryIndex to serve home.html is the default, but I'd recommend renaming home.html to index.html because 99% of web servers use index.html without any additional configuration. Jan 23, 2023 at 13:51
  • Thanks for your comments. Sorry, I tried to improve my original post to make my question more clear. Trying to improve the sitemap and .htaccess if needed.
    – Peter206
    Jan 25, 2023 at 9:36

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.