Alex
Alex

Reputation: 21

Jekyll: Including markdown files as variables to be {{ include.variable }} within the main markdown file

The reason for the include inside an include is to help remove the majority of html from new users who want to edit the markdown not familiar with HTML and CSS. I have tried to include twice but there is a syntax error.

Original-document.markdown

{% include template-document.markdown variable={% include To-add-document.markdown %} %}

Template-document.markdown

{{ include.variable }}

To-add-document.markdown

**Filler markdown text etc.**

I am not sure if it is possible to set markdown file as a variable, an alternative I have found on stackoverflow is to use collections. However all my values are unique and have different values. The current alternatives are to generate more markdown files with inbuilt values or combine HTML with Markdown. Both become messy for users.

Is it possible to include markdown files as variables?

Upvotes: 1

Views: 1163

Answers (1)

Alex
Alex

Reputation: 21

UPDATE:

I managed to solve it by making the variable a string which is the directory to the file.

Original-document.markdown

{% include template-document.markdown variable="To-add-document.markdown" %}

Template-document.markdown

{% include {{ include.variable }} %}

Upvotes: 1

Related Questions