Posted on 05/03/2017 17:27:54
Hi Nicolai,
I understand your concern, but maybe, you can help me out, with what I are trying to achive :-)
We are setting up the seo-part of a shop and need to specify the hreflang for the language layers: https://moz.com/learn/seo/hreflang-tag.
To optimize the urls we need to fill in the SEO-friendly url on each page no matter the user is reading a news, buying a product or reading a regular content page, so we are using the "Languages"-loop and need to replace the "ID" of the current url:
@foreach (var language in GetLoop("Languages"))
{
if (!string.IsNullOrEmpty(language.GetString("PrimaryDomain")))
{
var url = "https://" + language.GetString("PrimaryDomain") + "/" + Dynamicweb.Frontend.SearchEngineFriendlyURLs.GetFriendlyUrl(Base.ReplaceQueryString("ID", language.GetString("PageID")));
<link rel="alternate" hreflang='@GetHrefLang(language.GetString("Culture"))' href="@url" />
}
}
The issue here is that: Base.ReplaceQueryString("ID", language.GetString("PageID")) gives the new url with "ID" in the wrong location of the url, and now "GetInternalPageID" which is used by GetFriendlyUrl, is not working when displaying a e.g. product page; "Default.aspx?groupid=GROUP103&productid=3301&ID=2373"
Besides it will be great if the Language-loop could return the culture and the ssl-setting for the website, when more hardcoding can be avoided :-)
So how to solve this in a nice way instead of needing to build my own function for replacing the "ID=xxx"-part of the current url and still be able to use the built in functions in Dynamicweb?
Best regards, Anders