Jekyll Liquid - dynamic access to _config.yml

To internationalize my application, I need to be able to dynamically access the entries in the YAML file.

This is best explained by an example:

Page:

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

Then access to the variable title_homepage in the default template will be allowed:

Default layout:

page.title = "title_homepage"

Now I usually access my _config.yml file as follows:

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

However, now for this I need to access _config.yml with the value page.title. This will not work:

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

I need the following (pseudocode):

{{ site.locales[site.default_locale].#{value of page.title}}
+3
source share
1 answer

Given how your vars are installed, this would be something like strings

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

, ... . , - . ,

---
locale: en
title: My Wonderful Page
---

{{ page.title }}...

_config.yml?

() , page.title, /, , _config.yml.

+5

All Articles