Reputation: 342
I have a multilingual Jekyll website and I'm trying to build a page that uses an include that will append a file based on the language used but I'd like to avoid using an if statement.
I tried to use the following options without success:
{%- assign filename = "myFile." -%}
{%- assign lang = site.active_lang -%}
{%- assign fileExtension = ".html" -%}
{%- assign file = filename | append: lang | append: fileExtension -%}
{%- include file -%}
I was expecting the include to include run like this:
{%- include myfile.en.html -%}
But the include is adding a string into the page instead of the desired file.
Does anyone know if this is possible or I'll have to give up and use an if statement that is proven to work?
Upvotes: 2
Views: 412
Reputation: 342
Solved using {{}} around the variable, like this:
{%- include {{file}} -%}
Upvotes: 1