<turbo-stream action="append" target="posts_list"><template>    <div class="postbit" id="107163" data-post-id="107163">
  <section>
    <div class="post-wrap">


					<div class="post-header">
		        <div class="user-avatar">
		          <img alt="Cochonours" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/Cochonours/120/13516_2.png" width="120" height="120" />
		        </div>
					
						<div class="user-details">
		          <div class="user-name">
		            <h3>
                  Cochonours
                    <span class="op-star" title="Thread Starter">
                      <img alt="OP" class="op-star-icon" src="/assets/thread-icons/thread-icon-thread-starter-df91e872.png" />
                    </span>
                  </h3>
		          </div>
						
						</div>
					
					</div>

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<p>I have this for my landing page indeed!</p>
<p>Btw, I have a syntax problem with plugs: when used in a pipeline, we can set options after a comma like</p>
<pre data-code-wrap="elixir"><code class="lang-elixir">  pipeline :toto do
    plug Cldr.Plug.SetLocale,
      apps: [:cldr, :gettext],
      from: [:path, :accept_language],
      param: "locale",
      default: Cldr.default_locale,
      gettext: TotoWeb.Gettext
</code></pre>
<p>But how am I supposed to set those options if I want to use it after pipe_through instead (obviously the comma won’t do)?</p>
<pre data-code-wrap="elixir"><code class="lang-elixir">  scope "/", TotoWeb do
    pipe_through [:browser, Cldr.Plug.SetLocale ???]
</code></pre>
<p>I am using another pipeline so it’s not a big deal, but I am curious…</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="107163" data-batch-url="/posts/batch_likers">
                        0
                      </span>
                      <!-- <span class="thread-count js-solved-indicator" title="Marked as solution"></span> -->
	                </div>
	                <div class="go-to-post">
	                  <a title="Go to post" alt="Go to post" href="https://forum.elixirforum.com/t/router-controller-question-for-multi-lingual-website/18573/12">Post #11</a>
	                </div>
	            </div>
              <div id="likers-container-107163" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="107163"
                     data-batch-url="/posts/batch_likers">
                  <div class="post-likers"></div>
                </div>
              </div>
	        </div>
			

    </div>

    <div class="triangle-top-right type-standard-post cat-standard-post" title="Post #11"></div>
  </section>
</div>
    <div class="postbit" id="107435" data-post-id="107435">
  <section>
    <div class="post-wrap">


					<div class="post-header">
		        <div class="user-avatar">
		          <img alt="OvermindDL1" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/OvermindDL1/120/2677_2.png" width="120" height="120" />
		        </div>
					
						<div class="user-details">
		          <div class="user-name">
		            <h3>
                  OvermindDL1
                  </h3>
		          </div>
						
						</div>
					
					</div>

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<aside class="quote no-group" data-username="LostKobrakai" data-post="4" data-topic="18573" data-full="true">
<div class="title">
<div class="quote-controls"></div>
<img alt="" width="24" height="24" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/lostkobrakai/48/3072_2.png" class="avatar"> LostKobrakai:</div>
<blockquote>
<p>The header is nice as a default, but people might want so view a different language than the default one.</p>
</blockquote>
</aside>
<p>In most browsers you can set the language to send pretty easily, in other browsers (*cough*chrome*cough*) there are extensions that give you a click-drop-down box.  <img src="https://forum.elixirforum.com/images/emoji/apple/slight_smile.png?v=15" title=":slight_smile:" class="emoji" alt=":slight_smile:" loading="lazy" width="20" height="20"></p>
<p>Baking them into the URL’s mean that if you send someone a URL and they prefer another language then you lock them into a given language until they can somehow find out how to change it on the site (potentially in a language they are not strong with).</p>
<aside class="quote no-group" data-username="Cochonours" data-post="8" data-topic="18573" data-full="true">
<div class="title">
<div class="quote-controls"></div>
<img alt="" width="24" height="24" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/cochonours/48/13516_2.png" class="avatar"> Cochonours:</div>
<blockquote>
<p>That’s good to guess the default locale, but if you are not using your own browser you will not want to have the same links open in a locale you do not know. Also, as I want the urls to be different based on the locale, this wouldn’t do (aside from “/”).</p>
</blockquote>
</aside>
<p>Still pretty trivial to change the default in most browsers (even chrome without an extension just a few more clicks then).</p>
<aside class="quote no-group" data-username="Cochonours" data-post="8" data-topic="18573">
<div class="title">
<div class="quote-controls"></div>
<img alt="" width="24" height="24" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/cochonours/48/13516_2.png" class="avatar"> Cochonours:</div>
<blockquote>
<p>Also, as I want the urls to be different based on the locale, this wouldn’t do (aside from “/”).</p>
</blockquote>
</aside>
<p>That’s always painful though, you essentially have duplicated content then, and if search engines realize that then they downrank the site last I heard.</p>
<p>Overriding it with a query parameter I think is fine, but it should never be part of the path.</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="107435" data-batch-url="/posts/batch_likers">
                        0
                      </span>
                      <!-- <span class="thread-count js-solved-indicator" title="Marked as solution"></span> -->
	                </div>
	                <div class="go-to-post">
	                  <a title="Go to post" alt="Go to post" href="https://forum.elixirforum.com/t/router-controller-question-for-multi-lingual-website/18573/13">Post #12</a>
	                </div>
	            </div>
              <div id="likers-container-107435" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="107435"
                     data-batch-url="/posts/batch_likers">
                  <div class="post-likers"></div>
                </div>
              </div>
	        </div>
			

    </div>

    <div class="triangle-top-right type-standard-post cat-standard-post" title="Post #12"></div>
  </section>
</div>
    <div class="postbit" id="107449" data-post-id="107449">
  <section>
    <div class="post-wrap">


					<div class="post-header">
		        <div class="user-avatar">
		          <img alt="sfusato" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/sfusato/120/11569_2.png" width="120" height="120" />
		        </div>
					
						<div class="user-details">
		          <div class="user-name">
		            <h3>
                  sfusato
                  </h3>
		          </div>
						
						</div>
					
					</div>

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<aside class="quote no-group" data-username="OvermindDL1" data-post="13" data-topic="18573">
<div class="title">
<div class="quote-controls"></div>
<img alt="" width="24" height="24" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/overminddl1/48/2677_2.png" class="avatar"> OvermindDL1:</div>
<blockquote>
<p>Overriding it with a query parameter I think is fine, but it should never be part of the path.</p>
</blockquote>
</aside>
<p>How would you handle SEO, canonical url’s, alternative hreflang tags .etc ? For a publicly facing website you can’t ignore these, otherwise you will confuse the search engines.</p>
<p>Also, if you share/post a link somewhere, anyone following that might have a different Accept-Language header than yours (which the app also handles), will get something possibly different than what you might have wanted to share in the first place. Links should be resilient in this regard.</p>
<p><code>/paintings</code> won’t suffice in Italian anyway, where you might want to use <code>/dipinti</code> in this case</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="107449" data-batch-url="/posts/batch_likers">
                        1
                      </span>
                      <!-- <span class="thread-count js-solved-indicator" title="Marked as solution"></span> -->
	                </div>
	                <div class="go-to-post">
	                  <a title="Go to post" alt="Go to post" href="https://forum.elixirforum.com/t/router-controller-question-for-multi-lingual-website/18573/14">Post #13</a>
	                </div>
	            </div>
              <div id="likers-container-107449" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="107449"
                     data-batch-url="/posts/batch_likers">
                  <div class="post-likers"></div>
                </div>
              </div>
	        </div>
			

    </div>

    <div class="triangle-top-right type-standard-post cat-standard-post" title="Post #13"></div>
  </section>
</div>
    <div class="postbit" id="107451" data-post-id="107451">
  <section>
    <div class="post-wrap">


					<div class="post-header">
		        <div class="user-avatar">
		          <img alt="OvermindDL1" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/OvermindDL1/120/2677_2.png" width="120" height="120" />
		        </div>
					
						<div class="user-details">
		          <div class="user-name">
		            <h3>
                  OvermindDL1
                  </h3>
		          </div>
						
						</div>
					
					</div>

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<aside class="quote no-group" data-username="sfusato" data-post="14" data-topic="18573">
<div class="title">
<div class="quote-controls"></div>
<img alt="" width="24" height="24" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/sfusato/48/11569_2.png" class="avatar"> sfusato:</div>
<blockquote>
<p>How would you handle SEO, canonical url’s, alternative hreflang tags .etc ? For a publicly facing website you can’t ignore these, otherwise you will confuse the search engines.</p>
</blockquote>
</aside>
<p>That’s what the additional query parameters are for, and don’t forget to set the query-less version with <code>&lt;link rel="alternate" href="http://example.com/" hreflang="x-default" /&gt;</code> on each page as well and make sure all pages have all links to all the various languages of that same form and with an accept-language-less version defaulting to <code>en</code> as recommended <a href="https://support.google.com/webmasters/answer/189077?hl=en" rel="noopener nofollow ugc">by Google</a> (notice how google’s link even encodes the language as a query argument as well, and without it then it uses the header, and without that it defaults to <code>en</code>).</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="107451" data-batch-url="/posts/batch_likers">
                        0
                      </span>
                      <!-- <span class="thread-count js-solved-indicator" title="Marked as solution"></span> -->
	                </div>
	                <div class="go-to-post">
	                  <a title="Go to post" alt="Go to post" href="https://forum.elixirforum.com/t/router-controller-question-for-multi-lingual-website/18573/15">Post #14</a>
	                </div>
	            </div>
              <div id="likers-container-107451" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="107451"
                     data-batch-url="/posts/batch_likers">
                  <div class="post-likers"></div>
                </div>
              </div>
	        </div>
			

    </div>

    <div class="triangle-top-right type-standard-post cat-standard-post" title="Post #14"></div>
  </section>
</div>
    <div class="postbit" id="107474" data-post-id="107474">
  <section>
    <div class="post-wrap">


					<div class="post-header">
		        <div class="user-avatar">
		          <img alt="Cochonours" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/Cochonours/120/13516_2.png" width="120" height="120" />
		        </div>
					
						<div class="user-details">
		          <div class="user-name">
		            <h3>
                  Cochonours
                    <span class="op-star" title="Thread Starter">
                      <img alt="OP" class="op-star-icon" src="/assets/thread-icons/thread-icon-thread-starter-df91e872.png" />
                    </span>
                  </h3>
		          </div>
						
						</div>
					
					</div>

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<aside class="quote no-group" data-username="OvermindDL1" data-post="13" data-topic="18573" data-full="true">
<div class="title">
<div class="quote-controls"></div>
<img alt="" width="24" height="24" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/overminddl1/48/2677_2.png" class="avatar"> OvermindDL1:</div>
<blockquote>
<p>Still pretty trivial to change the default in most browsers (even chrome without an extension just a few more clicks then).</p>
</blockquote>
</aside>
<p>I’d wager most people do not know it’s even a possibility. As for myself, if it’s not my browser I won’t change such settings even if it’s easy.</p>
<aside class="quote no-group quote-modified" data-username="OvermindDL1" data-post="13" data-topic="18573" data-full="true">
<div class="title">
<div class="quote-controls"></div>
<img alt="" width="24" height="24" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/overminddl1/48/2677_2.png" class="avatar"> OvermindDL1:</div>
<blockquote>
<aside class="quote no-group" data-username="Cochonours" data-post="8" data-topic="18573">
<div class="title">
<div class="quote-controls"></div>
<img alt="" width="24" height="24" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/cochonours/48/13516_2.png" class="avatar"> Cochonours:</div>
<blockquote>
<p>Also, as I want the urls to be different based on the locale, this wouldn’t do (aside from “/”).</p>
</blockquote>
</aside>
<p>That’s always painful though, you essentially have duplicated content then, and if search engines realize that then they downrank the site last I heard.</p>
<p>Overriding it with a query parameter I think is fine, but it should never be part of the path.</p>
</blockquote>
</aside>
<p>It’s fine as long as I provide the urls for each locale in the header. Query parameters should absolutely not be used for locale switching.  Your own link from google in your next post makes it clear. Whether it’s the domain which changes or the path is not important (but not query params), as long as the localised links are provided.</p>
<p>Back to the topic, I’m still using my 3rd option and have thus one scope per locale. My problem is that to make it work I had to define one pipeline per locale, as I don’t know how to pass arguments/options to pipes I put in the pipe_through… Is there a way?</p>
<p>E.g. instead of <code>pipe_through [:browser_locale_fr]</code>, <code>pipe_through [:browser_locale_es]</code>, …, I’d like to have one pipeline and pass it the locale <code>pipe_through [:browser_locale ??? "fr" ???]</code>.</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="107474" data-batch-url="/posts/batch_likers">
                        0
                      </span>
                      <!-- <span class="thread-count js-solved-indicator" title="Marked as solution"></span> -->
	                </div>
	                <div class="go-to-post">
	                  <a title="Go to post" alt="Go to post" href="https://forum.elixirforum.com/t/router-controller-question-for-multi-lingual-website/18573/16">Post #15</a>
	                </div>
	            </div>
              <div id="likers-container-107474" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="107474"
                     data-batch-url="/posts/batch_likers">
                  <div class="post-likers"></div>
                </div>
              </div>
	        </div>
			

    </div>

    <div class="triangle-top-right type-standard-post cat-standard-post" title="Post #15"></div>
  </section>
</div>
    <div class="postbit" id="107530" data-post-id="107530">
  <section>
    <div class="post-wrap">


					<div class="post-header">
		        <div class="user-avatar">
		          <img alt="sfusato" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/sfusato/120/11569_2.png" width="120" height="120" />
		        </div>
					
						<div class="user-details">
		          <div class="user-name">
		            <h3>
                  sfusato
                  </h3>
		          </div>
						
						</div>
					
					</div>

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<p>How would your <code>alternate hreflang</code> tags differ from each other? Only through the query parameter ? Something like this for <code>example.com</code> homepage?</p>
<pre data-code-wrap="elixir"><code class="lang-elixir">&lt;link rel="alternate" href="http://example.com/?locale=en" hreflang="en" /&gt;
&lt;link rel="alternate" href="http://example.com/?locale=it" hreflang="it" /&gt;
&lt;link rel="alternate" href="http://example.com/" hreflang="x-default" /&gt;
</code></pre>
<p>Using query parameters for locale switching is strongly discouraged. I’m not surprised that Google breaks it’s own rules. That’s nothing new.</p>
<blockquote>
<h1>How Google crawls locale-adaptive pages</h1>
<p>If your site has  <em>locale-adaptive</em>  pages (that is, your site returns different content based on the perceived country or preferred language of the visitor), Google might not crawl, index, or rank all your content for different locales. This is because the default IP addresses of the Googlebot crawler appear to be based in the USA. In addition, the crawler sends HTTP requests without setting  <code>Accept-Language</code>  in the request header.</p>
<p>IMPORTANT:  <strong>We recommend</strong>  using separate locale URL configurations and annotating them with <a href="https://support.google.com/webmasters/answer/189077" rel="noopener nofollow ugc">rel=alternate hreflang annotations</a>.</p>
</blockquote>
<aside class="onebox allowlistedgeneric" data-onebox-src="https://developers.google.com/search/docs/specialty/international/locale-adaptive-pages?hl=en&amp;ref_topic=2370587&amp;visit_id=639184662088935853-76798148&amp;rd=1">
  <header class="source">
      <img src="https://www.gstatic.com/devrel-devsite/prod/v11431966d26d9f049ef61662c2b798f1cdee8af320f1ba0f77a43eee64301d60/developers/images/favicon-new.png" class="site-icon" alt="" width="24" height="24">

      <a href="https://developers.google.com/search/docs/specialty/international/locale-adaptive-pages?hl=en&amp;ref_topic=2370587&amp;visit_id=639184662088935853-76798148&amp;rd=1" target="_blank" rel="noopener nofollow ugc">Google for Developers</a>
  </header>

  <article class="onebox-body">
    <div class="aspect-image" style="--aspect-ratio:690/387;"><img src="https://developers.google.com/static/search/images/home-social-share-lockup.jpg" class="thumbnail" alt="" width="690" height="388"></div>

<h3><a href="https://developers.google.com/search/docs/specialty/international/locale-adaptive-pages?hl=en&amp;ref_topic=2370587&amp;visit_id=639184662088935853-76798148&amp;rd=1" target="_blank" rel="noopener nofollow ugc">How Google Crawls Locale-Adaptive Pages | Google Search Central &nbsp;|&nbsp;...</a></h3>

  <p>Learn the definition of locale-adaptive pages and why Google might not crawl, index, or rank all your content for different locales.</p>


  </article>

  <div class="onebox-metadata">
    
    
  </div>

  <div style="clear: both"></div>
</aside>

<blockquote>
<p>URL parameters<br>
<a href="http://site.com?loc=de" rel="noopener nofollow ugc">site.com?loc=de</a><br>
Not recommended.<br>
URL-based segmentation difficult<br>
Users might not recognize geotargeting from the URL alone<br>
Geotargeting in Search Console is not possible</p>
</blockquote>
<aside class="onebox allowlistedgeneric" data-onebox-src="https://developers.google.com/search/docs/specialty/international/managing-multi-regional-sites?hl=en&amp;visit_id=639184662126416168-1639315042&amp;rd=1">
  <header class="source">
      <img src="https://www.gstatic.com/devrel-devsite/prod/v11431966d26d9f049ef61662c2b798f1cdee8af320f1ba0f77a43eee64301d60/developers/images/favicon-new.png" class="site-icon" alt="" width="24" height="24">

      <a href="https://developers.google.com/search/docs/specialty/international/managing-multi-regional-sites?hl=en&amp;visit_id=639184662126416168-1639315042&amp;rd=1" target="_blank" rel="noopener nofollow ugc">Google for Developers</a>
  </header>

  <article class="onebox-body">
    <div class="aspect-image" style="--aspect-ratio:690/387;"><img src="https://developers.google.com/static/search/images/home-social-share-lockup.jpg" class="thumbnail" alt="" width="690" height="388"></div>

<h3><a href="https://developers.google.com/search/docs/specialty/international/managing-multi-regional-sites?hl=en&amp;visit_id=639184662126416168-1639315042&amp;rd=1" target="_blank" rel="noopener nofollow ugc">Managing Multi-Regional and Multilingual Sites | Google Search Central &nbsp;|&nbsp;...</a></h3>

  <p>Multi-regional and multilingual sites can be optimized for Search. Learn more about managing SEO for sites with multiple languages.</p>


  </article>

  <div class="onebox-metadata">
    
    
  </div>

  <div style="clear: both"></div>
</aside>
 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="107530" data-batch-url="/posts/batch_likers">
                        3
                      </span>
                      <!-- <span class="thread-count js-solved-indicator" title="Marked as solution"></span> -->
	                </div>
	                <div class="go-to-post">
	                  <a title="Go to post" alt="Go to post" href="https://forum.elixirforum.com/t/router-controller-question-for-multi-lingual-website/18573/17">Post #16</a>
	                </div>
	            </div>
              <div id="likers-container-107530" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="107530"
                     data-batch-url="/posts/batch_likers">
                  <div class="post-likers"></div>
                </div>
              </div>
	        </div>
			

    </div>

    <div class="triangle-top-right type-last-post cat-last-post" title="Last post!"></div>
  </section>
</div>
</template></turbo-stream><turbo-stream action="replace" target="load-more-container"><template><div id="load-more-container" class="load-more-container">
    <span class="all-loaded">— All posts loaded —</span>
</div></template></turbo-stream>