Streaming live at 10am (PST)

Language attribute on a collection page


#1

I want to use a collection for multiple languages. Everything is quite easy to set up and you can add different meta for each page, that’s awesome. Also easy to maintain design wise and through the editor. But what about the language attribute, how could we add that?

Is it possible to add that with JS, If so can some with right skills give the code needed?

Thanks for your help!


#2

@jorn take a look at this link Set language of document


#3

That piece of code might just work. Thanks Janne!


#4

It works! I added this code to my Collection page before end of body:

   <script>
 $(document).ready(function() {
  $('html').attr('lang','en');
 });
</script>

And used Add Field functionality from my collection to dynamically add the language code needed. My published page now shows the correct language attribute inside the html tag.

Curios if anyone sees any problem with this SEO wise?
Each item(page) in the collection will have their own language, meta title and description in their own language and the right language attribute. Only problem I can see is the URL’s. It would maybe be better to have folders named /sv and /en and so on but besides from that…


Any problems with this setup SEO wise?