# Multilanguage blog

**URL:** <https://forum.ghost.org/t/multilanguage-blog/13992>\
**Category:** Themes\
**Created:** [May 1, 2020, 1:36am UTC](https://forum.ghost.org/t/multilanguage-blog/13992 "2020-05-01T01:36:00Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![escudero](https://sea1.discourse-cdn.com/flex015/user_avatar/forum.ghost.org/escudero/32/7648_2.png) [@escudero](https://forum.ghost.org/u/escudero)\
**Post date:** [May 1, 2020, 1:36am UTC](https://forum.ghost.org/t/multilanguage-blog/13992/1 "2020-05-01T01:36:00Z")

</div>

I was following this tutorial: [Translation & Multi-language content](https://ghost.org/tutorials/multi-language-content/) but it got kinda blurry in the second step.

Just for clarification. I’m trying to have the site with english as a default and I also want to publish stuff in spanish.

In second step they’re talking about the lang attribute in the html tag, which isn’t present in the `index.hbs` but in the `default.hbs` instead. What should I do there? Should I copy the `default.hbs` and rename it to `es.hbs` so I can change the attribute properly? I don’t really understand.

---

<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 1, 2020, 10:45am UTC](https://forum.ghost.org/t/multilanguage-blog/13992/2 "2020-05-01T10:45:00Z")

</div>

Hey @escudero!

Dave here, I wrote the tutorial 😄. I can see why that point might be confusing.

### Plan A

One method of approaching this is to duplicate your templates and conditionally set them depending on the language. You would need to not only duplicate the `default.hbs` to `default-es.hbs` but also duplicate the page and post templates to `custom-post-es.hbs` and `custom-page-es.hbs` so you could reference the new default template with `{{!< default-es}}`. You would then need to select these templates in the post or page settings under the template select option when writing your english or spanish content.

The drawback to this is that this causes a lot of duplication, with many templates to manage in your theme. Plus you’d need to manually set the template as well as the internal tag for `es`.

### Plan B ⚡

Instead you could make use of the `block` and `contentFor` helpers, which let you insert code into your default template from your index, page and post templates. Rather than creating an additional `default-es.hbs`, `custom-post-es.hbs` and `custom-page-es.hbs` templates you could replace the opening `<html>` tag in your `default.hbs` template with the following:

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

```

Then in your `index-es.hbs` template you can set the `lang` value like so:

```auto
{{!< default}}

{{#contentFor "lang"}}es{{/contentFor}}

```

For posts and pages you can check for the internal tag and conditionally add the `lang` value:

```auto
{{!< default}}

{{#post}}
  {{#has tag="#es"}}
    {{#contentFor "lang"}}es{{/contentFor}}
  {{else}}
    {{#contentFor "lang"}}{{@site.lang}}{{/contentFor}}
  {{/has}}
{{/post}}

```

Does this help with what you’re trying to do? And do these methods appear very clear to you?

We’re going to update the guide from this feedback, and we’re in the process of documenting the `block` and `contentFor` helpers so developers can make use of them more in scenarios like this 👍

Let us know how you get on 😊

---

<div class="post-metadata">

**Author:** ![escudero](https://sea1.discourse-cdn.com/flex015/user_avatar/forum.ghost.org/escudero/32/7648_2.png) [@escudero](https://forum.ghost.org/u/escudero)\
**Post date:** [May 1, 2020, 11:48am UTC](https://forum.ghost.org/t/multilanguage-blog/13992/3 "2020-05-01T11:48:52Z")

</div>

I went with the “B” approach since it was much cleaner. It worked like a charm.

Thank you for helping out 👍

---

<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 1, 2020, 12:05pm UTC](https://forum.ghost.org/t/multilanguage-blog/13992/4 "2020-05-01T12:05:16Z")

</div>

Wonderful! Pleased I was able to help. I’m going to get on with updating our tutorial to include this step. Keep us posted on your progress! 🚀

---

<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 1, 2020, 5:03pm UTC](https://forum.ghost.org/t/multilanguage-blog/13992/5 "2020-05-01T17:03:42Z")

</div>

Hey again @escudero. I’ve spent some time updating our Multi-language tutorial to encompass the additions we talked about:  
[https://ghost.org/tutorials/multi-language-content/](https://ghost.org/tutorials/multi-language-content/)

This will help others in future who use this guide, so thank you for providing feedback!

Cheers, Dave

---

<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 19, 2020, 3:06pm UTC](https://forum.ghost.org/t/multilanguage-blog/13992/6 "2020-05-19T15:06:48Z")

</div>

Hey @escudero, just thought I’d let you know we’ve updated our docs to include the `block` and `contentFor` helpers which were the helpers I suggested for your `lang` issue. Hope this helps in future:

> **[Ghost Handlebars Theme Helpers: block & contentFor](https://ghost.org/docs/themes/helpers/block/)**
>
> Create templates that inherit reusable templates with handlebars block and contentFor helpers. Read more about Ghost themes! 👻

---

<div class="post-metadata">

**Author:** ![Julien\_Perron](https://sea1.discourse-cdn.com/flex015/user_avatar/forum.ghost.org/julien_perron/32/10431_2.png) [@Julien\_Perron](https://forum.ghost.org/u/Julien_Perron)\
**Post date:** [November 20, 2020, 1:59pm UTC](https://forum.ghost.org/t/multilanguage-blog/13992/7 "2020-11-20T13:59:06Z")

</div>

Hi @DavidDarnes, I tried to do this on my template and I followed exactly your tutorial. My default language is english (en) and I would like to have a translation in french (fr). For this, I did this :  
0. Imported my routes.yaml file :

```auto
routes:

collections:
  /:
    permalink: /{slug}/
    template: index
    filter: 'tag:-hash-fr'
    
  /fr/:
    permalink: /fr/{slug}/
    template: index-fr
    filter: 'tag:hash-fr'
    
taxonomies:
  tag: /tag/{slug}/
  author: /author/{slug}/

```

1. I replace the opening tag in my default.hbs template with the following:

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

```

1. Then in my `index-fr.hbs` template I set the `lang` value like so:

```auto
{{!< default}}

{{#contentFor "lang"}}fr{{/contentFor}}

```

1. Then, for posts and pages I added the `lang` value:

```auto
{{!< default}}

{{#post}}
  {{#has tag="#fr"}}
    {{#contentFor "lang"}}fr{{/contentFor}}
  {{else}}
    {{#contentFor "lang"}}{{@site.lang}}{{/contentFor}}
  {{/has}}
{{/post}}

```

1. I created my fr.json file with all the translations required and added it as a locale.

However, as you can see on my blog : [https://blog.askeetvirtual.com/](https://blog.askeetvirtual.com/), nothing changes when i’m going to [Blog | MeltingSpot](https://blog.askeetvirtual.com/fr/). Can you please help me ?

---

<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:** [November 21, 2020, 7:38pm UTC](https://forum.ghost.org/t/multilanguage-blog/13992/8 "2020-11-21T19:38:28Z")

</div>

Hey @Julien_Perron, you’ll notice in the tutorial there’s a note on why this isn’t behaving in the way you might be thinking:

> Note: **Locales and the publication language** are for setting **a single primary language** for the site. They are not designed to provide multiple languages at the same time.

You’ll need to create custom template files for your “fr” translated pages. You’ll need to customise your `index-fr.hbs` file with translated labelling.

Hope this is clear!

---

<div class="post-metadata">

**Author:** ![Ngoc\_Le](https://sea1.discourse-cdn.com/flex015/user_avatar/forum.ghost.org/ngoc_le/32/17235_2.png) [@Ngoc\_Le](https://forum.ghost.org/u/Ngoc_Le)\
**Post date:** [March 25, 2022, 4:31pm UTC](https://forum.ghost.org/t/multilanguage-blog/13992/9 "2022-03-25T16:31:18Z")

</div>

Hi @DavidDarnes

I followed your instruction. My website is  
[www.phuquocjapan.com](https://www.phuquocjapan.com) and when I try [ビンワンダー - phuquocjapan](http://www.phuquocjapan.com/vi), it shows 404 error. My primary language set in Ghost admin is Japanese. I created fine index-vi.hbs, duplicate from index.hbs, and edit {{#contentFor “lang”}}vi{{/contentFor}} below default.

Could you please help me?

Thank you very much.

---

<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:** [March 26, 2022, 11:29am UTC](https://forum.ghost.org/t/multilanguage-blog/13992/10 "2022-03-26T11:29:57Z")

</div>

Did you make sure to update your routes file as shown above?

---

<div class="post-metadata">

**Author:** ![Ngoc\_Le](https://sea1.discourse-cdn.com/flex015/user_avatar/forum.ghost.org/ngoc_le/32/17235_2.png) [@Ngoc\_Le](https://forum.ghost.org/u/Ngoc_Le)\
**Post date:** [March 28, 2022, 7:47am UTC](https://forum.ghost.org/t/multilanguage-blog/13992/11 "2022-03-28T07:47:12Z")

</div>

Thank you very much!
