It can work with Jekyll 3 now. Happy coding!
Visit Project Page for more information
Jekyll is very powerful. It is very conveniect to write bolg with Jekyll.
If we write mainly in English, and sometimes in other languages, now we can do this in a easy way.
THe default language:
-
Page:
$page_name.$ext. For example:index.md,about.md. -
Post:
_posts/$dir_pre/$date-$post_name.$ext. For example:_posts/blog/2014-02-26-hi.md.
The other language, short as $lang, put $lang and a dot . after $page_name or $post_name
-
Page:
page_name.$lang.$ext, for example:index.md=>index.cn.md -
Post:
_posts/$dir_pre/$date-$post_name.$ext2014-02-26.hi.md=>2014-02-26-hi.cn.md
-
The default language will build into destination directory as usually,
_site, for example. -
The other language (mark as:
$lang), will build into the subdirectory/$langin the destination directory.For example:
_site/$lang. If the$langisen, will be built into_site/en.
gem install jekyll-multiple-languagesIf you want you use pagination, you should install jekyll-paginate as well.
gem install jekyll-paginate-
# add this plugin to gems gems: ['jekyll-multiple-languages'] # if you want to use pagination, you should add jekyll-paginate into gems # and make sure it is in front of jekyll-multiple-languages # gems: ['jekyll-paginate', 'jekyll-multiple-languages'] # The all languages used languages: ['en', 'cn'] # If not config, the first item of languages will be used as the default. language_default: 'en'
-
Here is a sample projcet:
-
Here is the website of the sample projcet:
-
page.languageThe language in this Page or Post.
-
page.is_default_languageIf this Page or Post is in the default language, its value is
true
-
page.next_in_languageNext post in the same language with this post.
-
page.previous_in_languagePrevious post in the same language with this post.
-
site.pages_by_languageIt is all the
site.pagesgrouped by languages.It is a hash. The key is the language and the value is all of the Pages in this kind of language.
The value is a list.
-
site.posts_by_languageIt is similar to
site.pages_by_language, contains all thesite.postsgrouped by languages.
-
You can create a data file in the directory
_data, for example:i18n.yaml:en: previous_page: Previous next_page: Next cn: previous_page: 上一页 next_page: 下一页
-
Then use the language variables in
pagination.html:<li> <a href="{{ "{{ paginator.previous_page_path " }}}}" aria-label="Previous"> <span>{{ "{{ site.data.i18n[page.language].previous_page " }}}}</span> </a> </li>
This plugin enables that we can write blog in multiple languages easily, it also enables that we can use any files that end with differents extensions.
-
Page named
index.*is the paginate template for default language, no limited toindex.html.For example:
index.md,index.html. -
Page named
index.$lang.$extis the paginate template for the other languages(short for$lang).For example:
index.cn.md,index.html.
- Same with jekyll-paginate
Try to use Jekyll plugins on Github Pages is a little complicated.
And here is a solution.
t tag: https://github.com/screeninteraction/jekyll-multiple-languages-plugin