Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug in include alternate language pages #83

Open
bogdanstojanovic opened this issue Sep 17, 2018 · 2 comments
Open

Bug in include alternate language pages #83

bogdanstojanovic opened this issue Sep 17, 2018 · 2 comments

Comments

@bogdanstojanovic
Copy link

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.

@palle-mertz
Copy link

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;

}
`

@palle-mertz
Copy link

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 :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants