Developer forum

Forum » Templates » SearchFriendlyUrl for hreflang

SearchFriendlyUrl for hreflang

René Poulsen
Reply

Hi,

We've got a website with several different language versions. In the header I would like to create "hreflangs" for each language version of the current page.

Let's say i have a page on the english site with this URL: http://mynewbikeshop.com/bikes

Then, for the danish and swedish version, I would like to create hreflangs that looks like this:

<link rel="alternate" culture="da-DK" hreflang="http://mynewbikeshop.dk/cykler" />

<link rel="alternate" culture="sv-SE" hreflang="http://mynewbikeshop.se/cyklar" />

How do I get these searchfriendly URLs for each language version? I'v tried getting a pageview object, but it crashes the site in Safari and IE.


Replies

 
René Poulsen
Reply

Found a solution. Used Dynamicweb.Frontend.SearchEngineFriendlyURLs.GetFriendlyUrl instead:

@foreach (var language in GetLoop("Languages")) {
    string pageid = language.GetString("PageID");
    string url = language.GetString("PrimaryDomain") + Dynamicweb.Frontend.SearchEngineFriendlyURLs.GetFriendlyUrl("default.aspx?id=" + pageid);

    <link rel="alternate" href='@url' hreflang='@language.GetString("Culture")' />
}

 

You must be logged in to post in the forum