问题
I'm trying to build an include in Jekyll that has multiple variables, but the basic idea is that I'm wrapping multiple pieces of content in an anchor tag like the following:
<a href="#>
<h2>{{ include.piece-title }}</h2>
<h3>{{ include.piece-date }}</h3>
<img src="{{ include.piece-url }}" alt="{{ include.image-description }}">
<p>{{ include.piece-description }}</p>
</a>
However, this renders to the raw html (although the image works).
If I instead wrap it in a <figure>
tag instead of the <a>
tag, it doesn't have a problem. For example, this is fine:
<figure>
<h2>{{ include.piece-title }}</h2>
<h3>{{ include.piece-date }}</h3>
<img src="{{ include.piece-url }}" alt="{{ include.image-description }}">
<p>{{ include.piece-description }}</p>
</figure>
I can actually solve this by wrapping the <a>
tags in other html like <figure>
or <div>
like the following, but this seems a bit overkill:
<figure>
<a href="#">
<h2>{{ include.piece-title }}</h2>
<h3>{{ include.piece-date }}</h3>
<img src="{{ include.piece-url }}" alt="{{ include.image-description }}">
<p>{{ include.piece-description }}</p>
</a>
</figure>
I've been searching high and low, but I can't find anything that references behavior like this except the order of operations. I can't seem to see where this would break the order though.
来源:https://stackoverflow.com/questions/57218699/everything-between-anchor-tag-renders-raw-html-tags-in-jekyll-liquid