<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: aseycan</title>
    <description>The latest articles on DEV Community by aseycan (@aseycan).</description>
    <link>https://dev.to/aseycan</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F4284622%2F812965c0-648a-46f9-b0d2-f103a4c139e7.png</url>
      <title>DEV Community: aseycan</title>
      <link>https://dev.to/aseycan</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/aseycan"/>
    <language>en</language>
    <item>
      <title>My multilingual landing page had 2 clicks in 3 months. The fix was one URL per language</title>
      <dc:creator>aseycan</dc:creator>
      <pubDate>Sat, 05 Dec 2026 11:46:27 +0000</pubDate>
      <link>https://dev.to/aseycan/my-multilingual-landing-page-had-2-clicks-in-3-months-the-fix-was-one-url-per-language-1jhe</link>
      <guid>https://dev.to/aseycan/my-multilingual-landing-page-had-2-clicks-in-3-months-the-fix-was-one-url-per-language-1jhe</guid>
      <description>&lt;p&gt;I run a small React landing page in 8 languages. After three months, Google Search Console showed &lt;strong&gt;2 clicks and 11 impressions&lt;/strong&gt;. Most language versions were either "Crawled – currently not indexed" or flagged as &lt;strong&gt;"Duplicate, Google chose different canonical than user"&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;The content wasn't the problem. The URL structure was.&lt;/p&gt;

&lt;h2&gt;
  
  
  What was wrong
&lt;/h2&gt;

&lt;p&gt;The original setup was a single &lt;code&gt;index.html&lt;/code&gt; with a client-rendered React app:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Language came from &lt;code&gt;?lang=en&lt;/code&gt;, or from &lt;code&gt;navigator.language&lt;/code&gt; if there was no param.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;&amp;lt;title&amp;gt;&lt;/code&gt;, meta description and the canonical were set &lt;strong&gt;in JavaScript after load&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;Every language shared the same HTML shell, so the raw HTML was identical for &lt;code&gt;/&lt;/code&gt;, &lt;code&gt;/?lang=en&lt;/code&gt;, &lt;code&gt;/?lang=de&lt;/code&gt;...&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;From Google's point of view that's one page with a bunch of query-string variants. It picked one canonical and ignored the rest.&lt;/p&gt;

&lt;h2&gt;
  
  
  The fix: one real URL per language, prerendered
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Language = path.&lt;/strong&gt; &lt;code&gt;/&lt;/code&gt; (default), &lt;code&gt;/en/&lt;/code&gt;, &lt;code&gt;/de/&lt;/code&gt;, &lt;code&gt;/es/&lt;/code&gt;... &lt;code&gt;detectLang()&lt;/code&gt; now reads the path segment first and no longer redirects based on the browser language.
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;   &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;langPath&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;l&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;l&lt;/span&gt; &lt;span class="o"&gt;===&lt;/span&gt; &lt;span class="s2"&gt;"tr"&lt;/span&gt; &lt;span class="o"&gt;?&lt;/span&gt; &lt;span class="s2"&gt;"/"&lt;/span&gt; &lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"/"&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="n"&gt;l&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="s2"&gt;"/"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

   &lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;detectLang&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
     &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;typeof&lt;/span&gt; &lt;span class="nb"&gt;window&lt;/span&gt; &lt;span class="o"&gt;!==&lt;/span&gt; &lt;span class="s2"&gt;"undefined"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
       &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nb"&gt;window&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;__LANG__&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class="no"&gt;T&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nb"&gt;window&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;__LANG__&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nb"&gt;window&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;__LANG__&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
       &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;seg&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nb"&gt;window&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;location&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;pathname&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;split&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"/"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;||&lt;/span&gt; &lt;span class="s2"&gt;""&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;toLowerCase&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
       &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="no"&gt;T&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;seg&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;seg&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
     &lt;span class="p"&gt;}&lt;/span&gt;
     &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="s2"&gt;"tr"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
   &lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Prerender at build time.&lt;/strong&gt; A small Node script compiles the JSX with Babel, runs it in a &lt;code&gt;vm&lt;/code&gt; context, and calls &lt;code&gt;ReactDOMServer.renderToString(&amp;lt;App initialLang={l} /&amp;gt;)&lt;/code&gt; for each language. Each &lt;code&gt;/{lang}/index.html&lt;/code&gt; gets its own:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;code&gt;&amp;lt;html lang="..."&amp;gt;&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;title, description, OG/Twitter tags&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;self-referencing canonical&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;full &lt;code&gt;hreflang&lt;/code&gt; set (all languages + &lt;code&gt;x-default&lt;/code&gt;)&lt;/li&gt;
&lt;li&gt;JSON-LD (WebSite, Organization, FAQPage) in that language&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Hydrate instead of render.&lt;/strong&gt; The page sets &lt;code&gt;window.__LANG__&lt;/code&gt;, and the client calls &lt;code&gt;hydrateRoot&lt;/code&gt; when the root already has markup:&lt;br&gt;
&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;   &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;rootEl&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;document&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;getElementById&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"root"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
   &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;rootEl&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;hasChildNodes&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="nc"&gt;ReactDOM&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;hydrateRoot&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;rootEl&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nc"&gt;App&lt;/span&gt; &lt;span class="o"&gt;/&amp;gt;&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
   &lt;span class="k"&gt;else&lt;/span&gt; &lt;span class="nc"&gt;ReactDOM&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;createRoot&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;rootEl&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;render&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nc"&gt;App&lt;/span&gt; &lt;span class="o"&gt;/&amp;gt;&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The footer year was the only hydration mismatch. A &lt;code&gt;suppressHydrationWarning&lt;/code&gt; on that &lt;code&gt;&amp;lt;span&amp;gt;&lt;/code&gt; took care of it.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Real links for the language switcher.&lt;/strong&gt; &lt;code&gt;&amp;lt;a href="/de/" hreflang="de"&amp;gt;&lt;/code&gt; instead of an &lt;code&gt;onClick&lt;/code&gt; that changes state. Crawlers follow links, not click handlers.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;301 the old URLs&lt;/strong&gt; in nginx so existing links and indexed variants consolidate:&lt;br&gt;
&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight nginx"&gt;&lt;code&gt;   &lt;span class="na"&gt;location&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="o"&gt;/&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
       &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;$&lt;span class="n"&gt;arg_lang&lt;/span&gt; &lt;span class="o"&gt;~&lt;/span&gt; &lt;span class="s2"&gt;"^(en|es|pt|fr|de|ru|id)$"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="mi"&gt;301&lt;/span&gt; &lt;span class="o"&gt;/&lt;/span&gt;$&lt;span class="n"&gt;arg_lang&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;
       &lt;span class="na"&gt;if ($arg_lang&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;"tr"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="mi"&gt;301&lt;/span&gt; &lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;
       &lt;span class="na"&gt;try_files /index.html&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;404&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
   &lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Sitemap with hreflang alternates&lt;/strong&gt; for every landing URL, no query strings.&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  After deploying
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;curl&lt;/code&gt; each &lt;code&gt;/xx/&lt;/code&gt; URL and check &lt;code&gt;lang&lt;/code&gt;, canonical and hreflang &lt;strong&gt;in the raw HTML, before any JS runs&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;Resubmit the sitemap, request indexing for the main language URLs, and click &lt;strong&gt;"Validate fix"&lt;/strong&gt; on the duplicate/not-indexed issues in Search Console.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;I'll update this post with the before/after numbers once Google has recrawled.&lt;/p&gt;

&lt;h2&gt;
  
  
  Takeaways
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;If the language only exists after JavaScript runs, assume search engines see one page.&lt;/li&gt;
&lt;li&gt;Query-string language variants with a shared canonical will get collapsed.&lt;/li&gt;
&lt;li&gt;You don't need Next.js for this. A ~100-line prerender script plus &lt;code&gt;hydrateRoot&lt;/code&gt; was enough for a static landing page.&lt;/li&gt;
&lt;/ul&gt;




&lt;p&gt;&lt;em&gt;Disclosure: the site is a Hostinger referral page I run (&lt;a href="https://chefim.com/en/" rel="noopener noreferrer"&gt;chefim.com&lt;/a&gt;). If you're buying hosting anyway, the code &lt;code&gt;CHEFIM&lt;/code&gt; gives an extra discount on top of the sale price, and I get a commission. Not required to follow anything above.&lt;/em&gt;&lt;/p&gt;

</description>
      <category>seo</category>
      <category>react</category>
      <category>webdev</category>
      <category>i18n</category>
    </item>
  </channel>
</rss>
