Recently I was asked by one of our developers why the URL’s in the sitemap.xml file where changing based on the hostname used to visit the site. If we entered the site with http://www.hostname.com all the URL’s in the sitemap.xml started with http://www.hostname.com. But when we entered the site without the www part, so with http://hostname.com, all the URL’s in the sitemap.xml file changed to that one.
So you would end up with one site with unique pages but accessible from different URL’s and also a sitemap.xml that tells search engines the same thing. From a SEO perspective that is not what you want.
Luckily I learned that SXA has a thought about it. In the site settings part there is a field to enter a Target Hostname. Once filled in the sitemap.xml only uses this value regardless the hostnames with which you can access the site. Follow these simple steps and make your SEO consultants happy :).
- Go to /sitecore/content/Tenant Folder/Tenant/Site name/Settings/Site Grouping/Site name and look for the Target Hostname field.
- Fill in the hostname which you want to use in the sitemap.xml, save the change and publish it.
- Now check your sitemap.xml via multiple hostnames to check.