Dynamic variables Jekyll Liquid

I would like to use dynamic variables for my jekyll + liquid installation. I want to dynamically access the _config.yml file using a dynamic variable names.

This is best explained by an example:

Page:

---
layout: default
title: title_homepage
---

Default layout:

{{ site.locales[site.default_locale].page.title }}

_config.yml:

default_locale: "en"

locales:
  en:
    title_homepage: "This is my homepage title!"
  pirate:
    title_homepage: "Yaaawwwr. Homepage title."

So, how can I access _config.yml with the name of a dynamic variable?

+5
source share
2 answers

The title you want to pull out configures the site. Not the page itself. All you have to do is change the call to the default list by default:

{{ site.locales[site.default_locale].title_homepage }}

default_locale: "en", " !". _config.yml default_locale: "pirate", "Yaaawwwr. ". Jekyll 0.11.2, .

+3

Jekyll - -, . , , .

( - ):

root
  - _include
    home.html
  - _layout
    default.html
  - en
    index.html
  - pirate
    index.html
  index.html

, include {{content}} {% include index.html%}

_include/index.html:

<h1>{{page.title}}</h1>

ru/index.html:

---
layout: default
title: "This is my homepage title!"
---
{% include home.html %}

pirate/index.html:

---
layout: default
title: "Yaaawwwr. Homepage title."
---
{% include home.html %}

... .

URL- ....

, .

0

All Articles