如何通过不同的URL使用页面?

时间:2019-07-14 09:26:44

标签: jekyll

我正在构建一个基于Jekyll的博客,该博客提供四种语言版本。我希望翻译诸如索引之类的静态页面以及帖子。

我希望https://example.com/de/显示与https://example.com/gl/相同的文件,因为页面已经加载了翻译后的字符串。

现在,我在五个位置(index.html//es//en//gl/)中复制了相同的/de/config.yml根据路径设置site.lang变量。

index.html(及其四个副本)

<h1>site.t['latest'][page.lang]</h1>

config.yml

defaults:
  -
    scope:
      path: ""
    values:
      layout: "default"
  -
    scope:
      path: "es"
    values:
      lang: "es"
  -
    scope:
      path: "en"
    values:
      lang: "en"
  -
    scope:
      path: "gl"
    values:
      lang: "gl"
  -
    scope:
      path: "de"
    values:
      lang: "de"

t:
  latest:
    es: "Últimas publicaciones"
    gl: "Últimas publicacións"
    en: "Latest posts"
    de: "Neueste Beiträge"
  back:
    es: "Volver atrás"
    gl: "Voltar atrás"
    en: "Go back"
    de: "Zurück gehen"

我希望在构建之前只能拥有一个index.html,并能够通过五个不同的URL浏览它。

当浏览除/之外的任何URL时,在根中仅具有索引的实际输出为404错误。

0 个答案:

没有答案
相关问题