Baike.dev
All toolsOnline toolsAI codingTrendingOpen sourceNewsSubmit
Log in
< Back to tools
J

jekyll-multiple-languages-plugin

> 编程语言
Open source

I18n support for Jekyll and Octopress

936 stars0 likes3 views
WebsiteGitHub

About

I18n support for Jekyll and Octopress

Jekyll Multiple Languages Plugin

Jekyll Multiple Languages is an internationalization plugin for Jekyll. It compiles your Jekyll site for one or more languages with a similar approach as Rails does. The different sites will be stored in subfolders with the same name as the language it contains.

The plugin was developed as a utility at Daresay

Badges

!! We are looking for more maintainers !!

Are you using this plugin? Could you test and verify incoming PRs? Please give us a shout!

Table of Contents

  • Jekyll Multiple Languages Plugin
    • Badges
    • !! We are looking for more maintainers !!
    • Table of Contents
    • 1. Current Release Notice
    • 2. Features
    • 3. Installation
      • 3.1. Using the gem
      • 3.2. Manually
      • 3.3. As a Git Submodule
    • 4. Configuration
      • 4.1. _config.yml
      • 4.2. Folder structure
    • 5. Usage
      • 5.1. Translating strings
      • 5.2. Including translated files
      • 5.3. Permalinks and Translating Links
      • 5.4. i18n in templates
      • 5.5. Link between languages
      • 5.6. Creating pages
      • 5.7. Creating posts
      • 5.8. Select pages to translations
    • 6. License
    • 7. Example website
      • 7.1. Adding a new language
      • 7.2. Adding new page
    • 8. Changelog
    • 9. Contributing
      • Contributors
      • Created by
      • Maintained by
      • Former maintainer
    • 10. Other Language Plugins

1. Current Release Notice

1.6.0 is the current stable release.

The support for Octopress is dropped, but the plugin should still work with it since Octopress core is Jekyll. Octopress 3 now has its own multi languages plugin: https://github.com/octopress/multilingual

2. Features

  • Supports multiple languages with the same code base.
  • Supports all template languages that your Liquid pipeline supports.
  • Uses Liquid tags in your HTML for including translated strings.
  • Compiles the site multiple times for all supported languages into separate subfolders.
  • Works with the --watch flag turned on and will rebuild all languages automatically.
  • Contains an example website, thanks to @davrandom
  • Supports translated keys in YAML format
  • Supports translated template files
  • Supports translated links

3. Installation

3.1. Using the gem

This plugin is available as a Ruby gem, https://rubygems.org/gems/jekyll-multiple-languages-plugin.

Add this line to your application's Gemfile:

gem 'jekyll-multiple-languages-plugin'

And then execute: $ bundle install

Or install it yourself as: $ gem install jekyll-multiple-languages-plugin

To activate the plugin add it to the Jekyll _config.yml file, under the plugins option:

ruby
plugins:
  - jekyll-multiple-languages-plugin

See the Jekyll configuration documentation for details.

3.2. Manually

  1. Download the repository with Git or your preferred method.
  2. Inside your Jekyll _plugins folder, create a new folder called jekyll-multiple-languages-plugin.
  3. Copy or link the directory lib, that is inside the downloaded repository, into your _plugins/jekyll-multiple-languages-plugin folder of your Jekyll project.

3.3. As a Git Submodule

If your Jekyll project is in a git repository, you can easily manage your plugins by utilizing git submodules.

To install this plugin as a git submodule:

bash
$ git submodule add git://github.com/screeninteraction/jekyll-multiple-languages-plugin.git _plugins/multiple-languages

To update:

bash
$ cd _plugins/multiple-languages
$ git pull origin master

4. Configuration

4.1. _config.yml

Add the languages available in your website into your _config.yml (obligatory):

yaml
languages: ["sv", "en", "de", "fr"]

The first language in the array will be the default language, English, German and French will be added into separate subfolders.

To avoid redundancy, it is possible to exclude files and folders from being copied to the localization folders.

yaml
exclude_from_localizations: ["javascript", "images", "css"]

In code, these specific files should be referenced via baseurl_root. E.g.

If you wish to avoid having the default_lang built into the root of your website, use:

yaml
default_locale_in_subfolder: true

4.2. Folder structure

Create a folder called _i18n and add sub-folders for each language, using the same names used on the languages setting on the _config.yml:

  • /_i18n/sv.yml
  • /_i18n/en.yml
  • /_i18n/de.yml
  • /_i18n/fr.yml
  • /_i18n/sv/pagename/blockname.md
  • /_i18n/en/pagename/blockname.md
  • /_i18n/de/pagename/blockname.md
  • /_i18n/fr/pagename/blockname.md

5. Usage

5.1. Translating strings

To add a translated string into your web page, use one of these liquid tags:

liquid
{% t key %}
or
{% translate key %}

This will pick the correct string from the language.yml file during compilation.

The language.yml files are written in YAML syntax which caters for a simple grouping of strings.

yaml
global:
  swedish: Svenska
  english: English
pages:
  home: Home
  work: Work

To access the english key, use one of these tags:

liquid
{% t global.english %}
or
{% translate global.english %}

You can also access translated strings by accessing the site.translations hash, this allows you to loop through your translations within Liquid using the translated string's index:

liquid
{% for item in site.translations[site.lang].my_nested_yaml_collection %}
    
{{ item[0] }} -> {{ item[1] }}

{% endfor %}

or the translated string's assignment:

yaml
my_nested_yaml_collection:
  -
    title: First
    message: Message
  -
    title: Second
    message: Message
liquid
{% for item in site.translations[site.lang].my_nested_yaml_collection %}
   

      
{{ item["title"] }}

      
{{ item["message"] }}

   

{% endfor %}

5.2. Including translated files

The plugin also supports using different markdown files for different languages using the liquid tag:

liquid
{% tf pagename/blockname.md %}
or
{% translate_file pagename/blockname.md %}

This plugin has exactly the same support and syntax as the Jekyll's built in liquid tag:

liquid
{% include file %}

so plugins that extend its functionality should be picked up by this plugin as well.

5.3. Permalinks and Translating Links

To use localized pages with permalinks, you must provide a default permalink and the language specific permalinks, for example, permalink_fr for French.

To translate links, you must also add a unique namespace on the YAML front matter along with the permalinks.

Example:

yaml
---
layout:         default

namespace:     team

permalink:      /team/
permalink_fr:   /equipe/
---

And then you can use the translate link liquid tag like this:

liquid
 

 

or the longer version:

 

 

5.4. i18n in templates

Sometimes it is convenient to add keys even in template files. This works in the exact same way as in ordinary files, however sometimes it can be useful to include a different string in different pages even if they use the same template.

A perfect example is this:

xml

  
    {% t page.title %}
  

So how can I add different translated titles to all pages? Don't worry, it's easy. The Multiple Languages plugin supports Liquid variables, as well as strings so, define a page variable in your page definition

yaml
---
layout: default
title: titles.home
---

and {% t page.title %} will pick up the titles.home key from language.yml

yaml
titles:
  home: "Home"

5.5. Link between languages

This plugin gives you the variables

liquid
{{ site.lang }}

and

{{ site.baseurl_root }}

to play with in your template files.

This allows you to create solutions like this:

liquid
{% if site.lang == "sv" %}
  {% capture link1 %}{{ site.baseurl_root }}/en{{ page.url}}{% endcapture %}
  {% t global.english %}
{% elsif site.lang == "en" %}
  {% capture link2 %}{{ site.baseurl_root }}{{ page.url  }}{% endcapture %}
  {% t global.swedish %}
{% endif %}

This snippet will create a link that will toggle between Swedish and English. A more detailed description of the variables used follows:

Name Value Example
site.lang The language used in the current compilation stage en
site.baseurl Points to the root of the site including the current language http://foo.bar/en
site.baseurl_root Points to the root of the page without the language path http://foo.bar
page.url The current page's relative URL to the baseurl /a/sub/folder/page/

5.6. Creating pages

Depending on the theme, or your preferences, you need to create a "template" page in the root folder or in a folder (ex. _pages). Inside each page (in this example an about.md) you should have at least the following in the header and body:

yaml
---
layout: page
title: About
permalink: /about/
---

{% translate_file about/about.md %}

Inside each of the language folders, you should create mirror pages to provide the actual content for that language (ex. i18n/es/about/about.md). Make sure to erase the headers from those md files, or else your site will break.

5.7. Creating posts

There are no global posts. The posts are localized by language. And your posts will live in the _i18n/[lang]/_posts directory. So if, for example, you have English language on your website you should put your posts on _i18n/en/_posts directory.

5.8. Select pages to translations

Sometimes you want to generate only selected versions of the page, especially excluding default language. You can do this using languages tag.

Example:

yaml
---
permalink:      /team/
permalink_fr:   /equipe/

languages: ["fr"]
---

This generate only french version of the page.

6. License

This project is available under the MIT License.

7. Example website

This repository has an example website where you can test the plugin. After downloading the repository, get into the example directory and run: bundle install to install the newest version of Jekyll (edit the Gemfile to install another version) and all other dependencies.

Then run bundle exec jekyll serve to start the Jekyll server. Using your web browser, access the address http://localhost:4000.

7.1. Adding a new language

Imagine you want to add German pages on the test website. First, add a new language to the list of languages on _config.yml:

ruby
languages: ["it", "en", "es", "de"]

Create a new folder for the language under the _i18n folder and add a markdown file containing the translation, just like on the other language folders, and you're done.

7.2. Adding new page

Let's say you want to create a

Issues· 0 open

View all issuesOpen on GitHub

No open issues yet, or sync has not completed.

> Tags

Ruby

No comments yet. Be the first to share.

> Details

PublishedAug 1, 2026
UpdatedSep 17, 2026
Category编程语言
PricingOpen source

> Related tools

T
TypeScript
JavaScript 的超集,为前端与全栈提供静态类型
P
Python
通用编程语言,广泛用于 Web、数据与 AI
G
Go
Google 推出的简洁高效系统语言