# How to configure route filter for multi-language pages

**URL:** <https://forum.ghost.org/t/how-to-configure-route-filter-for-multi-language-pages/14137>\
**Category:** Developer help\
**Created:** [May 7, 2020, 7:35am UTC](https://forum.ghost.org/t/how-to-configure-route-filter-for-multi-language-pages/14137 "2020-05-07T07:35:58Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![beautycss](https://sea1.discourse-cdn.com/flex015/user_avatar/forum.ghost.org/beautycss/32/7747_2.png) [@beautycss](https://forum.ghost.org/u/beautycss)\
**Post date:** [May 7, 2020, 7:35am UTC](https://forum.ghost.org/t/how-to-configure-route-filter-for-multi-language-pages/14137/1 "2020-05-07T07:35:58Z")

</div>

I configure collections for multi-language pages as this tutorial([https://ghost.org/tutorials/multi-language-content/](https://ghost.org/tutorials/multi-language-content/)).Now my three collections works, I can visit either /cn /en, or /tw index page.  
Then I create two “stars” pages, one is “en” tag and the other is “cn” tag.  
I want to visit English page “stars” and show English page.But if I visit /en/stars, it shows 404.I tried to change the Publication Language to en, but visit /stars is still cn page.

Questions:

1. How to configure the collections filter or page url to visit /en/stars and show English “stars” page?
2. I want to add a language select in frontend page for user to switch language, is there any api to change the ghost site language with Javascript?

Thanks.

- **Version** 3.2.0
- **Environment** production
- **Database** sqlite3

Here are my config.

collections:

```auto
routes:

collections:
  /:
    permalink: /{slug}/
    data: page.home
    template: index
    filter: 'tag:-[cn,en,tw]'
  /cn/:
    permalink: /cn/{slug}/
    data: page.home
    template: index
    filter: 'tag:cn'
  /en/:
    permalink: /en/{slug}/
    data: page.home
    template: index-en
    filter: 'tag:en'
  /tw/:
    permalink: /tw/{slug}/
    data: page.home
    template: index
    filter: 'tag:tw'

taxonomies:
  tag: /tag/{slug}/
  author: /author/{slug}/

```

My Settings:

 ![IMG_4859](https://us1.discourse-cdn.com/flex015/uploads/ghost2/original/2X/1/1798374a8c832e9ef20ff656f9ac3a4fd5336c43.jpeg)

---

<div class="post-metadata">

**Author:** ![DavidDarnes](https://sea1.discourse-cdn.com/flex015/user_avatar/forum.ghost.org/daviddarnes/32/3533_2.png) [@DavidDarnes](https://forum.ghost.org/u/DavidDarnes)\
**Post date:** [May 11, 2020, 8:14am UTC](https://forum.ghost.org/t/how-to-configure-route-filter-for-multi-language-pages/14137/2 "2020-05-11T08:14:49Z")

</div>

Hey @beautycss,

Looks like you’re using internal tags to filter your content but aren’t referencing them quite right in the routes file. Your collections definition should look something like this:

```auto
collections:
  /:
    permalink: /{slug}/
    data: page.home
    template: index
    filter: 'tag:-[hash-cn,hash-en,hash-tw]'
  /cn/:
    permalink: /cn/{slug}/
    data: page.home
    template: index
    filter: 'tag:hash-cn'
  /en/:
    permalink: /en/{slug}/
    data: page.home
    template: index-en
    filter: 'tag:hash-en'
  /tw/:
    permalink: /tw/{slug}/
    data: page.home
    template: index
    filter: 'tag:hash-tw' 

```

When you want to use an internal tag within the routes file you need to prefix it with `hash-`. Hope this helps! 😊

---

<div class="post-metadata">

**Author:** ![beautycss](https://sea1.discourse-cdn.com/flex015/user_avatar/forum.ghost.org/beautycss/32/7747_2.png) [@beautycss](https://forum.ghost.org/u/beautycss)\
**Post date:** [May 15, 2020, 3:35am UTC](https://forum.ghost.org/t/how-to-configure-route-filter-for-multi-language-pages/14137/3 "2020-05-15T03:35:10Z")

</div>

Thanks, I update as your config, but still not work.  
And the locale doesn’t work now.It always show cn lang after I change to en lang in “general”.

```auto
routes:

collections:
  /:
    permalink: /{slug}/
    data: page.home
    template: index
    filter: 'tag:-[hash-cn,hash-en,hash-tw]'
  /cn/:
    permalink: /cn/{slug}/
    data: page.home
    template: index
    filter: 'tag:hash-cn'
  /en/:
    permalink: /en/{slug}/
    data: page.home
    template: index
    filter: 'tag:hash-en'
  /tw/:
    permalink: /tw/{slug}/
    data: page.home
    template: index
    filter: 'tag:hash-tw'

taxonomies:
  tag: /tag/{slug}/
  author: /author/{slug}/

```

 ![WX20200515-113809](https://us1.discourse-cdn.com/flex015/uploads/ghost2/original/2X/a/a0f9acf7a8a91757e8102cee70ba1f921d3dbd2f.png)  
is tag configed right?

---

<div class="post-metadata">

**Author:** ![DavidDarnes](https://sea1.discourse-cdn.com/flex015/user_avatar/forum.ghost.org/daviddarnes/32/3533_2.png) [@DavidDarnes](https://forum.ghost.org/u/DavidDarnes)\
**Post date:** [May 15, 2020, 2:24pm UTC](https://forum.ghost.org/t/how-to-configure-route-filter-for-multi-language-pages/14137/4 "2020-05-15T14:24:22Z")

</div>

Would you be able to share your site as well? Might help us debug what’s wrong. Looks like your `#tw` tag has been renamed to `#w`, this could cause issues so might be best to change the name back

---

<div class="post-metadata">

**Author:** ![beautycss](https://sea1.discourse-cdn.com/flex015/user_avatar/forum.ghost.org/beautycss/32/7747_2.png) [@beautycss](https://forum.ghost.org/u/beautycss)\
**Post date:** [May 27, 2020, 7:33am UTC](https://forum.ghost.org/t/how-to-configure-route-filter-for-multi-language-pages/14137/5 "2020-05-27T07:33:12Z")

</div>

Hi, the site url is [http://47.112.100.140:9001/](http://47.112.100.140:9001/).  
Now the site locale is en.

What I Expect:  
I have “Simplified Chinese”, “Traditional Chinese”, “English” Three languages on the top of the page:  
If I’m visiting “[http://47.112.100.140:9001/contact-us](http://47.112.100.140:9001/contact-us)” page, and I want to redirect to “[http://47.112.100.140:9001/en/contact-us](http://47.112.100.140:9001/en/contact-us)” if I click the English on the top of the page.

the site backend account:  
teenmix/teenmix2020

Thanks.

---

<div class="post-metadata">

**Author:** ![DavidDarnes](https://sea1.discourse-cdn.com/flex015/user_avatar/forum.ghost.org/daviddarnes/32/3533_2.png) [@DavidDarnes](https://forum.ghost.org/u/DavidDarnes)\
**Post date:** [May 28, 2020, 1:39pm UTC](https://forum.ghost.org/t/how-to-configure-route-filter-for-multi-language-pages/14137/6 "2020-05-28T13:39:46Z")

</div>

You’ll need to customise the navigation in that case, by creating a custom set of navigation items in partials for each language. Those partials will then need to be included in their respective template files, so en readers will get directed to the en contact page. Does that make sense?

---

<div class="post-metadata">

**Author:** ![beautycss](https://sea1.discourse-cdn.com/flex015/user_avatar/forum.ghost.org/beautycss/32/7747_2.png) [@beautycss](https://forum.ghost.org/u/beautycss)\
**Post date:** [May 29, 2020, 10:02am UTC](https://forum.ghost.org/t/how-to-configure-route-filter-for-multi-language-pages/14137/7 "2020-05-29T10:02:38Z")

</div>

Do you mean that the url won’t need to change if I change language?the url always is ‘[http://47.112.100.140:9001/contact-us](http://47.112.100.140:9001/contact-us)’ instead of “[http://47.112.100.140:9001/en/contact-us”](http://47.112.100.140:9001/en/contact-us%E2%80%9D) .  
Now I care this question:  
if I put “Simplified Chinese”, “Traditional Chinese”, “English” Three language buttons on header of the template page, how to change the site locale in template file, is there any javascript api?

---

<div class="post-metadata">

**Author:** ![DavidDarnes](https://sea1.discourse-cdn.com/flex015/user_avatar/forum.ghost.org/daviddarnes/32/3533_2.png) [@DavidDarnes](https://forum.ghost.org/u/DavidDarnes)\
**Post date:** [June 1, 2020, 4:18pm UTC](https://forum.ghost.org/t/how-to-configure-route-filter-for-multi-language-pages/14137/8 "2020-06-01T16:18:05Z")

</div>

I mean that you’ll need to link to “en” pages when viewing “en” pages. There’s a section [here in our multi-language tutorial](https://ghost.org/tutorials/multi-language-content/#create-templates-for-translated-collections) which shows how to apply the lang attribute value for different languages:

```auto
<html lang="{{{block "lang"}}}">

```

```auto
{{#post}}
  {{#has tag="#de"}}
    {{#contentFor "lang"}}de{{/contentFor}}
  {{else}}
    {{#contentFor "lang"}}{{@site.lang}}{{/contentFor}}
  {{/has}}
{{/post}}

```

For language switching you’ll need to link to their counterpart pages, those links can be captured either by adding [languages alternatives](https://support.google.com/webmasters/answer/189077?hl=en) in the `head` or by using JavaScript to calculate the link.

Hope this helps!
