HufflepuffBR HufflepuffBR - 1 month ago 6
YAML Question

Expanding variables into Jekyll Front-End

It is possible to expand a variable into a post Front-Matter?

I use a series of items for links into my template, like:

- text: foo
link: bar

But sometimes I need to refer to other posts into my site. Normally I would use just
into link, but this is also used as shownotes into a podcast, I want to expand the link for
. But using
{% post_url YYYY-MM-DD-bar %}
results into:

Error: could not read file [REDACTED]: (<unknown>): found character that cannot start any token while scanning for the next token at line 33 column 12

Any tips?


I found a more elegant at my own:

{% assign %}
{% assign link_start = real_link | slice: 0 %}
{% if  link_start == "/" %}{% assign real_link = real_link | prepend: site.url %}{% endif %}

As I start al my locak links with a / to warrant that the link will be related with the root in the site, that was a better way for me.