I'm trying to get Jekyll to generate a link dynamically. The link is for a CSS file, but depends on the page that is being rendered.
i.e. If the page was contact, it should render mywebsite.com/lib/css/contact.css
The problem I have is that When I try to nest liquid tags, it can't resolve the name properly. It seems to treat the entire string as literal string instead of resolving the name.
I've tried the following:
Note: layout.cssFile is a page variable that contains the name of the CSS file I wish to render.
Attempt 1:
<link href="{{ lib/css/" | append: layout.cssFile }} | relative_url }}" rel="stylesheet">
Attempt 2:
<link href="{{ "lib/css/{{ layout.cssFile }} | relative_url }}" rel="stylesheet">
Attempt 3:
{% assign cssPath="lib/css/{{layout.cssFile}}" %}
<link href="{{ cssPath | relative_url }}" rel="stylesheet">
None of these things work. How can I write this in a clean way that is easy to read and does what I want?