Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs: Update internationalization.md #1570

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 35 additions & 0 deletions source/docs/internationalization.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,41 @@ index:
// 3 videos
```

### Index files for languages

For each language that you want to serve content in, you might want to create an index file. This way your index page will be also rendered in each language that you are serving. To do this, you need to create regular markdown pages located in folders whose names are the languages code and refer to the index template (Where you are supposed to use the ```__() or _p()``` translation helpers). For instance:

```
└── workspace/
└── source/
├── _posts/
│ ├── en/
│ │ ├── welcome.md
│ │ ├── blogpost.md
│ │ └── ...
│ └── de/
│ ├── willkommen.md
│ ├── blogpost.md
│ └── ...
├── en/
│ └── index.md
└── de/
└── index.md

```
For these index files you only need to define the layout property in the frontmatter so your index page is rendered using that layout.

You can also add the alias property so / redirects to your default locale e.g. /de/

```
---
layout: index
alias: index.html
---
```

It's no wonder you are getting 404 for /xx-yy/ if you have not created the index page for the specific language.

### Path

You can set the language of pages in front-matter, or modify the `i18n_dir` setting in `_config.yml` to enable automatic detection by Hexo.
Expand Down