Multi-language blog
There are a few ways to set up a multi-language blog on Bear. Below are the most common methods. All of the examples will use English and French as the two languages.
Use two separate blogs and interlink them
This is the simplest approach. Write one blog in English, and one blog in French. You can then subdomain the blogs to represent the languages with either a custom domain (eg: fr.myblog.com
) or using the Bear subdomain (eg: myblog-fr.bearblog.dev
).
On the home page, in the nav, or in the footer (or anywhere else that supports content on Bear) add a link to the other language blog in the form of something like:
[Read this blog in French](https://fr.myblog.com)
This method relies on an upgraded account which can handle multiple blogs. Ensure you set the lang
attribute for the blog so that it is filtered correctly in the Bear discovery feed and by search engines.
Use tag filters
This method uses one blog, but allows you to write in multiple languages. It works by tagging posts as a specific language, then using filters to correctly categorise them.
- Set your blog
lang
attribute to the most used language (eg:lang: en
) - On each post set the relevant
lang
attribute (eg:lang: fr
). - On each post set a
tag
specifying the language of the post (eg:tags: French
)
Now in your blog's Nav
(or anywhere that supports content on Bear) you can specify a tag filtered blog list using the /blog/?q=French
query. Eg:
[Home](/) [English posts](/blog/?q=English) [Articles français](/blog/?q=French)
This could be used in homepage content instead with something along the lines of:
Lis [mes articles en français](/blog/?q=French)
Using post list embeds
This method uses one blog, but allows you to write in multiple languages. It works by tagging posts as a specific language, then using embedded post lists to correctly categorise them.
Similarly to the previous method you'll need to categories the posts like this:
- Set your blog
lang
attribute to the most used language (eg:lang: en
) - On each post set the relevant
lang
attribute (eg:lang: fr
). - On each post set a
tag
specifying the language of the post (eg:tags: French
)
Then create a page
(called something like Articles français
) and in that page set the content to:
# Articles français
{{ posts|tag:French }}
You can do the same thing for English posts
.
Note that this method doesn't allow filtering further by tags, since post embeds don't support tag filtering.
Final thoughts
There are a few other, more esoteric ways to handle this. I've seen some examples of using <details><summary>Read in English<summary>...
, and others where people get creative with Javascript. The world is your mollusk.
Any great ideas to add to this docs page? Send me an email.