2
votes

How do I use a variable from the site _config.yml in a posts frontmatter?

I would like to do something like

---
github-id: site.github-id
---

However this literally sets it to the string "site.github-id".

1
You can't use liquid variable in front matter.David Jacquel
I gathered that, so what would be the neatest way of achieving this functionality?Jacob Tomlinson
What functionality? you'd like a user declared var to be displayed where? the posts title?Harry Moreno
Yes that could be one example.Jacob Tomlinson
Unfortunately jeykll does not support liquid tags within front matter. You have a great work around though. Can you post it as an answer and mark it as correct to close the questionAntK

1 Answers

1
votes

It seems this isn't currently possible due to limitations of Jekyll.

As a work around you can do something along these lines:

{% if page.github-id %}
 {{ page.github-id }}
{% else %}
 {{ site.github-id }}
{% endif %}