This isn’t working for me:
The name of the file you want to link can be specified as a variable instead of an actual file name. For example, suppose you defined a variable in your page’s front matter like this:
--- title: My page my_variable: footer_company_a.html ---
You could then reference that variable in your link:
{% link {{ page.my_variable }} %}
In this example, the
link
tag would render a link to the filefooter_company_a.html
.
I’ve tried both declaring a variable in the front matter using a hardcoded path, such as:
icon_path: assets/images/components/clutch.png
and using:
{% assign icon_path = component_page.slug | prepend: assets/images/ | append: ".png" %}
<img src="{% link {{ icon_path }} %}"/>
to do it for a bunch of icons in a loop.
Either way I get an error like this:
Liquid Exception: Could not find document ‘{{ icon_path }}’ in tag ‘link’. Make sure the document exists and the path is correct. in /_layouts/components-index.html
jekyll 3.9.2 | Error: Could not find document ‘{{ icon_path }}’ in tag ‘link’.Make sure the document exists and the path is correct.
The error message just shows whichever expression I put to the right of the {% link
leading me to believe that it’s insistently trying to interpret the argument as a literal path despite the double-braces.
The images show up fine when I don’t use the link tag:
<img src="/assets/images/components/{{ component_page.slug }}.png"/>
but I’d like to have Jekyll detect broken links / missing files.
Has this feature been removed from Jekyll?