You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have noticed a bug recently while making sitemap. We have few different hosts names with assigned culture codes in single site structure. Like said host names have assigned culture, with primary type and https scheme under website settings.
However this is current sitemap result. Worth to mention that hostname and website_url are different domains:
It will force-use the host from the sitemap data (look at the relevant code from below snipped from SitemapXmlGenerator), which is the host that it is currently generating the sitemap for.
Too me it looks like intended behavior (because of the comment "Force the SiteUrl"), al though I really cannot think of any reason for this behavior, but of course saying that I do not have an overview of all different setup scenarios.
If the else statement is removed the url should already include the host from the primary host definition for that language (it did in my tests of this) that it gets from the UrlResolver. I can see that it is old code (from 2014?) so this code might be related to some legacy behaviour from the UrlResolver :)
Imho removing the else statement should fix the problem.
And on a side note ... it is not easily overridden either as this method is not marked as virtual.
`
protected string GetAbsoluteUrl(string url)
{
Uri absoluteUri;
// if the URL is relative we add the base site URL (protocol and hostname)
if (!IsAbsoluteUrl(url, out absoluteUri))
{
url = UriSupport.Combine(this.SitemapData.SiteUrl, url);
}
// Force the SiteUrl
else
{
url = UriSupport.Combine(this.SitemapData.SiteUrl, absoluteUri.AbsolutePath);
}
return url;
Ok maybe not that hard to overwrite ... as you only have to move up once and override CreateHrefLangData and get the absolute url without the else statement ... but still not optimal :)
I have noticed a bug recently while making sitemap. We have few different hosts names with assigned culture codes in single site structure. Like said host names have assigned culture, with primary type and https scheme under website settings.
However this is current sitemap result. Worth to mention that hostname and website_url are different domains:
<url> <loc>https://hostname/fr-be/solutions-chimiques-et-environnementales/</loc> <lastmod>2018-06-29T11:30:31+00:00</lastmod> <changefreq>weekly</changefreq> <priority>0.5</priority> <xhtml:link rel="alternate" hreflang="nl-nl" href="https://website_url/chemische-en-milieuoplossingen/nox-reductie-voor-industrie/service-en-apparatuur-voor-denox-systemen/gebruik-en-opslag/" /> <xhtml:link rel="alternate" hreflang="nl-be" href="https://website_url/chemische-en-milieuoplossingen/nox-reductie-voor-industrie/services-for-nox-control-systems/gebruik-en-opslag/" /> <xhtml:link rel="alternate" hreflang="fr-be" href="https://website_url/fr-be/solutions-chimiques-et-environnementales/reduction-de-nox-pour-les-usines/service-en-apparatuur-voor-denox-systemen/handling-and-storage/" /> </url>
What we want to achieve:
<url> <loc>https://hostname/fr-be/solutions-chimiques-et-environnementales/</loc> <lastmod>2018-06-29T11:30:31+00:00</lastmod> <changefreq>weekly</changefreq> <priority>0.5</priority> <xhtml:link rel="alternate" hreflang="nl-nl" href="https://website_url/chemische-en-milieuoplossingen/nox-reductie-voor-industrie/service-en-apparatuur-voor-denox-systemen/gebruik-en-opslag/" /> <xhtml:link rel="alternate" hreflang="nl-be" href="https://hostname/chemische-en-milieuoplossingen/nox-reductie-voor-industrie/services-for-nox-control-systems/gebruik-en-opslag/" /> <xhtml:link rel="alternate" hreflang="fr-be" href="https://hostname/fr-be/solutions-chimiques-et-environnementales/reduction-de-nox-pour-les-usines/service-en-apparatuur-voor-denox-systemen/handling-and-storage/" /> </url>
Notice difference in the last two hreflang nodes.
The text was updated successfully, but these errors were encountered: