Skip to content
Discussion options

You must be logged in to vote

I'll assume you're using LiquidJS as the default .md layout engine, but this should do the trick.
Not sure how nicely LiquidJS plays w/ string+variable concatenation, so I usually opt to just pre-set the value in a variable and then pass that along (see assign tag below):

{% for article in collections.news %}
  {% comment %} This successfully reads the filePathStem variable {% endcomment %}
  "{{ article.filePathStem }}.jpg"

  {% comment %} This doesn't read the variable successfully {% endcomment %}
  {%- assign src = article.filePathStem | append: ".jpg" -%}
  {% image src, "Argument" %}
{% endfor %}

OUTPUT

"/news/five.jpg"
<img src="/news/five.jpg" alt="Argument" />

"/news/four.jpg"
<

Replies: 2 comments 1 reply

Comment options

You must be logged in to vote
1 reply
@pdehaan
Comment options

pdehaan Mar 4, 2023
Collaborator

Answer selected by manforowicz
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants