Dynamic Variables Jekyll Liquid

后端 未结 2 1318
渐次进展
渐次进展 2021-02-09 22:09

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

It is best

2条回答
  •  一生所求
    2021-02-09 22:29

    Jekyll is a static website generator, its unable to usa a variable. But I guess for locale it self, there are one simple solution.

    Follow this file structure (or something like that):

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

    That simple, now use include for {{content}} and create simple files with variables and one single line {% include index.html %}

    _include/index.html :

    {{page.title}}

    en/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 %}
    

    So... that is it.

    Now create a page variable to handle locale urls for each page....

    I hope this help.

提交回复
热议问题