Reputation: 4484
I only found there is config file to set the language. But I want user could select it and change dynamically. Just like Hexo home page did https://hexo.io/docs/internationalization.html.
Upvotes: 1
Views: 541
Reputation: 238
I think this may be helpful: https://hexo.io/docs/permalinks.html#Multi-language-Support
first, edit _config.yml
and setting new_post_name
and permalink
.
new_post_name: :lang/:title.md
permalink: :lang/:title/
then, create a new post should save as this:
hexo new "Hello World" --lang tw
finally, when you traverse each post to show them, you can use post.lang
to decide show it or not.
<% page.posts.each(function(post) { %>
<% if (post.lang === ('tw')) { %>
<%- partial('_partial/article') %>
<% } %>
<% }); %>
Upvotes: 2