
















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.
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.
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.
lang attribute to the most used language (eg: lang: en)lang attribute (eg: lang: fr).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)
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:
lang attribute to the most used language (eg: lang: en)lang attribute (eg: lang: fr).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.
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.
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。