Answers.Body: <p>I'm assuming /fr/ is for language and /park/ is the slug of the Locations entry? Is /brussels/ also the slug for another entry, or is it just a key you're using to determine what content to show on the Park page?</p>
  <p>In config/routes.php you can set up a route for the French site like this:</p>
  <pre><code>return [
    'fr' =&gt; [
      &lt;citySlug&gt;/&lt;entrySlug:{slug}&gt;' =&gt; ['template' =&gt; '_location']
    ]
  ];
  </code></pre>
  <p>And then in the _location.twig template, you'll be able to access citySlug variable (e.g. 'new-york'). You could then use that to find and display the relevant content. How you do that will depend on whether that content lives on the Park entry, or if you have to query some other entry for it.</p>
  <p>Just note that because there's no static base URL segment here (e.g. /fr/<strong>locations</strong>/new-york/park/) you might have to do some additional logic to make sure the route doesn't unintentionally affect other sections.</p>
  <p>EDIT: I may have misunderstood the intent here. Is this just entries in the locations section that have slightly different content based on the city? Or is it more like each city has totally different content for the same (or a similar) set of entries? You may actually just want to create multiple sites (one for each language/city combo) instead of doing the above.</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2023-09-18T20:15:47.083Z
Answers.Text: /fr is indeed for language, /brussels is the location, and /park is the name of the page. This could just as well be /about. There is a park in Brussels and a park in New York. This should use the same template but have different content.
  Each city will have different content like attractions and other accommodations.
  Multiple sites might be the correct approach here actually. I just need to make sure it still is easily manageable for the client.
Answers.UserDisplayName: Matthias
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2023-09-18T15:32:58.603Z
Answers.LastActivityDate: 2023-09-18T15:45:09.133Z
Answers.LastEditDate: 2023-09-18T15:45:09.133Z
Answers.UserDisplayName: GTerrill
Body: <p>We're building a website for a company with multiple locations which need different content but based on the same templates.</p>
  <p>I currently have a section <code>Locations</code>.
  What I want to achieve is to structure the URL's as follows:</p>
  <ul>
  <li>mywebsite.com/fr/brussels/park</li>
  <li>mywebsite.com/fr/new-york/park</li>
  </ul>
  <p>How can I achieve this result?</p>
  <p>I have found a similar question from 2015 but this might be outdated: <a href="https://craftcms.stackexchange.com/questions/6680/show-content-based-on-chosen-city">Show content based on chosen city</a></p>
  
Tags: <craft4><routing>
Title: Add chosen location in URL and show content accordingly
ThreadText: # Add chosen location in URL and show content accordingly
  
  (Asked by: username_0 on 2023-09-18)
  
  We're building a website for a company with multiple locations which need different content but based on the same templates.
  
  I currently have a section `Locations`.
  What I want to achieve is to structure the URL's as follows:
  
  * mywebsite.com/fr/brussels/park
  * mywebsite.com/fr/new-york/park
  
  How can I achieve this result?
  
  I have found a similar question from 2015 but this might be outdated: [Show content based on chosen city](https://craftcms.stackexchange.com/questions/6680/show-content-based-on-chosen-city)
  
  **Tags:** craft4, routing
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2023-09-18. Score: 2 | Accepted answer
  
  I'm assuming /fr/ is for language and /park/ is the slug of the Locations entry? Is /brussels/ also the slug for another entry, or is it just a key you're using to determine what content to show on the Park page?
  
  In config/routes.php you can set up a route for the French site like this:
  
  ```
  return [
    'fr' => [
      <citySlug>/<entrySlug:{slug}>' => ['template' => '_location']
    ]
  ];
  
  ```
  
  And then in the \_location.twig template, you'll be able to access citySlug variable (e.g. 'new-york'). You could then use that to find and display the relevant content. How you do that will depend on whether that content lives on the Park entry, or if you have to query some other entry for it.
  
  Just note that because there's no static base URL segment here (e.g. /fr/**locations**/new-york/park/) you might have to do some additional logic to make sure the route doesn't unintentionally affect other sections.
  
  EDIT: I may have misunderstood the intent here. Is this just entries in the locations section that have slightly different content based on the city? Or is it more like each city has totally different content for the same (or a similar) set of entries? You may actually just want to create multiple sites (one for each language/city combo) instead of doing the above.
  
  > **Comments:**
  > **username_0**: /fr is indeed for language, /brussels is the location, and /park is the name of the page. This could just as well be /about. There is a park in Brussels and a park in New York. This should use the same template but have different content. Each city will have different content like attractions and other accommodations. Multiple sites might be the correct approach here actually. I just need to make sure it still is easily manageable for the client.  
  
  ---
  
  