Help shape the future of CMS PaaS release notes! Take this quick survey and share your feedback.
Help shape the future of CMS PaaS release notes! Take this quick survey and share your feedback.
Jim,
This topic provides an introduction to globalization and language management for version 8 Episerver platform: https://world.episerver.com/documentation/Items/Developers-Guide/Episerver-CMS/8/Globalization/Globalization/.
Jim
Thanks for the reference, let me explain futher. The marketing company has given me several sets of tags each contain variations of the following on a page by page basis. They insist that these tags need to be added to the pages themselves. However epi uses a root masterpage and content templates. how would I add this set of tags to the aboutus page.
<link rel="alternate" hreflang="x-default" href="https://www.blah.com/about-us/" />
<link rel="alternate" hreflang="en-AU" href="https://www.blah.com.au/about-us/" />
<link rel="alternate" hreflang="en-CA" href="https://www.blah.ca/about-us/" />
Thansk so much
There is a HtmlHelper available that will render out these tags for you based on what languages your pages are available in
@Html.AlternateLinks()
This helper takes into account the page access rights / published status etc. It will show the href as the primary host name that you have bound to your site (following the ruiles in the documentation above). We put this call in our Layout page so it appears on any content page
N.B. These tags don't help customers be served the right language page, instead they help search engines index and understand language variants of a piece of content
Mark
Can this tag be used in a webforms implementation of Episerver??
In fact we are not concerned about the language being served, just the order of the search results.
Thanks
There is a WebControl, but it looks like this feature was only added sometime in the Version 9 CMS release cycle.
https://world.episerver.com/documentation/Class-library/?documentId=cms/9/AFB0A735
The functionality isn't hard to replicate yourself. The below code will get you all available language variants from the current page, filtered by access rights, publish status etc.
var pageLanguagesBranches = contentRepository.GetLanguageBranches<PageData>(CurrentPage.ContentLink).ToList();
var availablePageLanguages = FilterForVisitor.Filter(pageLanguagesBranches).OfType<PageData>();
You'd just need to iterate through that data and calculate the correct host to produce markup as above.
Hi there,
I am trying to use the suggested code snippet by Mark Erverad in my HtmlHelpers.cs:
I pasted it as if into the file, but Visual Studio showed up some errors. So far I have the following:
var pageLanguagesBranches = ContentRepository.GetLanguageBranches<PageData>(ICurrentPage.ContentLink).ToList();
var availablePageLanguages = FilterForVisitor.Filter(pageLanguagesBranches).OfType<PageData>();
Visual Studio is informing me that ICurrentPage does not contain a definition for ContentLink.
Any help would be really appreciated.
CurrentPage right? Not ICurrentPage. You should have that as a parameter in your controller.
Hreflang tags are good to have yes if you have many languages. It helps google to determine what version to display for the current user in the search result.
epiNew: It looks like you are trying the GetLanguageBranches method without obtaining an instance of IContentRepository.
If you are doing this in an extension method, you can inject IContentRepository in the static extension class like this:
private static readonly Injected<IContentRepository> _contentRepository = default(Injected<IContentRepository>);
Then rewrite line 1 of your code like this, assuming you pass in a PageData instance, called currentPage:
var pageLanguagesBranches = _contentRepository.Service.GetLanguageBranches<PageData>(currentPage.ContentLink).ToList();
Thanks in advance for your assistance.
I have not spent a lot of time in the CMS side of the side versus Commerce and we need to add HREFLANG tags to all of our sites so that users will get the correct content when they browse and log in.
What is the easiest way to add these tags to the websites?
We are using Episerver CMS version 8.1