1 year ago

#382800

test-img

Marlony Gabriel

Mkdocs with material theme: is it possible to change site name according to language?

I'm making a documentation site using Mkdocs and mkdocs-material theme (https://squidfunk.github.io/mkdocs-material/getting-started/). I need to make a multilanguage project ('pt' and 'en' for now). What i'm in need is a way to change the site name according to language that the person ir reading. E.G: I'm in Brazil, so i'll read in portuguese (pt), and the site name must be "Name in Portuguese". Another reader, in USA, for example, will read in english so the site name muste be changed to "Name in English".

My project till now is with a tree of docs like this:

docs/
|
|__ index.md
|
├─ en/
│  ├─ somefile1.md
|  |__ somefile2.md  
├─ pt/
│  ├─ otherfile1.md
|  |__ otherfile2.md

My yaml mkdocs.yml file configuration is in the root of project, one level above the docs dir (standard for mkdocs).

    site_name: Name in Portugese
    site_url: mysiteproject.com
    
    nav:
       - index.md
       - Ajuda: 
         - pt/otherfile1.md
         - pt/otherfile2.md
       - Help:
         - en/somefile1.md
         - en/somefile2.md

theme:
  name: material
  logo: imgs/logo-serpro.png
  favicon: imgs/favicon.png
  language: pt
  font:
    text: Open Sans


markdown_extensions:
  attr_list: {}
  admonition: {}
  codehilite: {}
  meta: {}

extra_css:
  - css/extra.css

So, what I need is, when the reader is navigating the site on "Ajuda" section, the site name will be in portuguese. If the reader is on "Help" section the site name change to "Name in English".

mkdocs

0 Answers

Your Answer

Accepted video resources