Sharcoux
Sharcoux

Reputation: 6105

single page website translation, indexation and SEO

I have a webpage, let say www.mypage.com/index.html. I have a javascript function able to fill the page with my own translation of the content thanks to json dictionaries. In the end, www.mypage.com/?lang=en will display the content and fill it with the english language. www.mypage.com/?lang=fr will display the content and fill it with the french language.

For instance :

<html><head>
    <script type="text/javascript">
        translate(getURLParameter("lang"));
    </script>
</head><body>
    <p id="content0">default content</p>
</body></html>

The translate method will transform :

<p id="content0">default content</p>

into

<p id="content0">translated content</p>

This is what I'm currently able to do. What I would like is a solution to simulate an english webpage and a distinct french webpage, without duplicate content, and optimized for SEO. I need to keep using my dictionaries as the translation is in there.

My website is hosted on an Apache 2 server if it helps.

edit: I thought I would necessary need to do that in php (a language I don't know very well), but thanks to the hreflang meta, I think there could be a trick to do it in HTML+JS. Any hint ?

Thank you !

Upvotes: 0

Views: 462

Answers (1)

Tim
Tim

Reputation: 2922

Typically you do something like this and do a static pre-render so the crawler gets the keywords you want. There are various ways to do this but I really like this one.

https://prerender.io/

Upvotes: 1

Related Questions