Im trying to output front matter variables depending on the current Jekyll environment.
For example, if the current environment is dev
I would like the variable dev
to be displayed:
---
something:
dev: "Some text"
production: "Other text
---
I'm trying to access the variable dev with the following method and I get no result:
{{ page.something.jekyll.environment }}
Is there a better way to do this?
I don't think you can access front matter in this way.
Instead, you coud assign the dev
variable in your html template, with the environment as a conditional:
---
layout: default
---
{% if jekyll.environment == "dev" %}
{% assign dev = "this is dev" %}
{% endif %}
<div id="page-content">
{{dev}}
...
</div>
You could also directly wrap the relevant element in an if statement in the template.