<p>I set up 2 sites (locally) running Craft 3.6.7:</p>
<ul>
<li>English (Handle: <strong>english</strong>, Base URL: '/en/')</li>
<li>German (Handle: <strong>german</strong>, Base URL: '/de/')</li>
</ul>
<p>I've made a blog section that is enabled for both languages with a 'blog/{slug}' URI for both and they also use the same template '_blog/_entry'.</p>
<p>There is a single blog post which translates on both languages, with slugs 'test-english' (for the <strong>english</strong> locale)' and test-german' (for the <strong>german</strong> locale).</p>
<p>Both posts are accessible as expected using '/en/blog/test-english' and '/de/blog/test-german'. The problem is when I try to link to an entry, the URL that's returned is always 'blog/test-english' or 'blog/test-german', without the Base URL, so the <strong>german</strong> URL never works ('blog/test-german' doesn't exist).</p>
<p>I've been looking everywhere trying to find if this is the expected behavior, but everything points in the direction it's not. Thank you in advance!</p>
<p>Edit:</p>
<p>This is part of my current navigation that shows the 2 latest posts related to the current site. One of the URLs it returns (without '/en') is: 'blog/get-upselling-inspiration-with-the-deal-library'.</p>
<pre><code>{% set latestPosts = craft.entries().section('blog').siteId(currentSite.id).limit(2) %}

{% if latestPosts.exists() %}
  &lt;ul class=&quot;navigation-dropdown__posts&quot;&gt;
    {% for post in latestPosts.all() %}
      &lt;li class=&quot;navigation-dropdown__post&quot;&gt;
        &lt;a class=&quot;navigation-dropdown__anchor&quot; href=&quot;{{ post.url }}&quot;&gt;
          {% if post.singleImage|length %}
            {% for image in post.singleImage.all() %}
              &lt;img class=&quot;navigation-dropdown__image&quot; src=&quot;{{ image.getUrl('blogThumbnail') }}&quot; alt=&quot;{{ image.title }}&quot; /&gt;
            {% endfor %}
          {% endif %}
          &lt;strong&gt;{{ post.title }}&lt;/strong&gt;
        &lt;/a&gt;
      &lt;/li&gt;
    {% endfor %}
  &lt;/ul&gt;
{% endif %}
</code></pre>
<p>Edit 2: Solved it for now like this, but I don't think this is how it's supposed to work</p>
<pre><code>{% for siteForEntry in entry.getSupportedSites %}
  {# get the site #}
  {% set site = craft.app.getSites.getSiteById(siteForEntry.siteId) %}
  {# check if it's the current site #}
  {% if site.id == entry.siteId %}
    &lt;option value=&quot;{{ site.handle }}&quot; selected&gt;{{ site.name }}&lt;/option&gt;
  {% else %}
    {% set entryForOtherSite = craft.entries.id(entry.id).site(site).one() %}
    {# if it's not the current site, get the entry for this site #}
    {% if entryForOtherSite.uri == '__home__' %}
      {% set prettyUrl = site.baseUrl() %}
    {% else %}
      {% set prettyUrl = site.baseUrl() ~ entryForOtherSite.uri %}
    {% endif %}

    &lt;option value=&quot;{{ site.handle }}&quot; onclick=&quot;location.href='{{ prettyUrl }}';&quot;&gt;{{ site.name }}&lt;/option&gt;
  {% endif %}
{% endfor %}
</code></pre>

CC BY-SA 4.0
2021-02-24T16:59:11.437Z
Can you show the code you have in your template?
Oli
CC BY-SA 4.0
2021-02-25T11:45:06.687Z
@Oli I added the navigation template code to the original post, thank you!
Gideon
<localization><entry><multi-site><siteurl>
Entry URLs are not returning URL with locale in the path
# Entry URLs are not returning URL with locale in the path

(Asked by: username_0 on 2021-02-24)

I set up 2 sites (locally) running Craft 3.6.7:

English (Handle: english, Base URL: '/en/')
German (Handle: german, Base URL: '/de/')

I've made a blog section that is enabled for both languages with a 'blog/{slug}' URI for both and they also use the same template '_blog/_entry'.
There is a single blog post which translates on both languages, with slugs 'test-english' (for the english locale)' and test-german' (for the german locale).
Both posts are accessible as expected using '/en/blog/test-english' and '/de/blog/test-german'. The problem is when I try to link to an entry, the URL that's returned is always 'blog/test-english' or 'blog/test-german', without the Base URL, so the german URL never works ('blog/test-german' doesn't exist).
I've been looking everywhere trying to find if this is the expected behavior, but everything points in the direction it's not. Thank you in advance!
Edit:
This is part of my current navigation that shows the 2 latest posts related to the current site. One of the URLs it returns (without '/en') is: 'blog/get-upselling-inspiration-with-the-deal-library'.
{% set latestPosts = craft.entries().section('blog').siteId(currentSite.id).limit(2) %}

{% if latestPosts.exists() %}
  
    {% for post in latestPosts.all() %}
      
        
          {% if post.singleImage|length %}
            {% for image in post.singleImage.all() %}
              
            {% endfor %}
          {% endif %}
          {{ post.title }}
        
      
    {% endfor %}
  
{% endif %}

Edit 2: Solved it for now like this, but I don't think this is how it's supposed to work
{% for siteForEntry in entry.getSupportedSites %}
  {# get the site #}
  {% set site = craft.app.getSites.getSiteById(siteForEntry.siteId) %}
  {# check if it's the current site #}
  {% if site.id == entry.siteId %}
    {{ site.name }}
  {% else %}
    {% set entryForOtherSite = craft.entries.id(entry.id).site(site).one() %}
    {# if it's not the current site, get the entry for this site #}
    {% if entryForOtherSite.uri == '__home__' %}
      {% set prettyUrl = site.baseUrl() %}
    {% else %}
      {% set prettyUrl = site.baseUrl() ~ entryForOtherSite.uri %}
    {% endif %}

    {{ site.name }}
  {% endif %}
{% endfor %}

**Tags:** localization, entry, multi-site, siteurl
> **Comments:**
> **username_1**: Can you show the code you have in your template?  
> **username_0**: @Oli I added the navigation template code to the original post, thank you!  

---

## 0 answers

