Do you want to create a multilingual blog with jekyll? Here’s an easy way to setup jekyll to have content in multiple languages.

Create localized string data file

Create a folder named _data if you don’t already have one. Inside that folder, create a localization data file and name it messages.yml.

mkdir _data
touch messages.yml

Edit messages.yml and add localized strings. For the moment, I will just create a simple phrase and 2 localized strings in English and Vietnamese for testing purpose.

locales:
  en:
    example: "example"
  vn:
    example: "Ví dụ"

Display localized strings on post/page

Now you need to capture the locale of the current page. You can do it either by capturing the url (if you organize posts by folders of language’s name) or from the page variable. To make it easy in this port, i will use the current page’s locale variable; if not specified then default to ‘en’.

locale: "vn"

Get the localized string with this syntax

{{ site.data.messages.locales[locale].example }}

And that’s it. Go back and add more localized strings, update templates and publish changes. Your website is now multilingual.

To make it even more visitor-friendly, you can create a separate RSS feed for each one of the language.

Alternatively, you can use jekyll-multiple-languages-plugin1, though I’m not a big fan of using plugin when not I don’t really need to.

  1. http://rubydoc.info/gems/jekyll-multiple-languages-plugin/1.2.5/frames