Reputation: 780
I've looked around a bit and everything is telling me that [link](path)
should create link markup. I however cannot get it to work for some reason.
I originally tried [my link]({{ site.baseurl }}{% link _my_collection/my-file.md %})
and it just prints out [my link](my/correct/path)
, but is not creating the markup. I also tried [link text](https://google.com)
with the same result. Does anyone know what I could be missing, perhaps some gem?
Using jekyll 3.7.2
Upvotes: 1
Views: 1508
Reputation: 1
For anyone stumbling into issues with rendering links in markdown files between Liquid blocks, don't indent the tag expression!
{% for post in site.posts %}}
<a href="{{post.url}}">{{post.title}}</a>
{% endfor %}
Produces: <a href="post-url">post-title</a>
Whereas
{% for post in site.posts %}
<a href="{{post.url}}>{{post.title}}</a>"
{% endfor %}
Produces a working link!
Upvotes: 0
Reputation: 780
I had forgotten this about this question. It does not appear that there is any way that Jekyll can translate this markup directly but I did manage a workaround with the markdown
text filter:
{%- capture links -%}
[my link]({{ site.baseurl }}{% link _my_collection/my-file.md %})
[my link](my/correct/path)
[link text](https://google.com)
{%- endcapture -%}
{# Remove <p> tags that markdownify seems to add #}
{{ links | markdownify | remove: '<p>' | remove: '</p>' }}
Upvotes: 0
Reputation: 52789
You're probably using your markdown inside html block elements (p, h1, ...). And kramdown, by default, doesn't parse markdown in such tags.
In order to parse md inside html block elements, you can configure kramdown like this :
_config.yml
kramdown:
parse_block_html: true
Upvotes: 1