Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How do I use absolute_url/relative_url in combination with link? #6521

Closed
jameshfisher opened this issue Nov 5, 2017 · 3 comments
Closed

Comments

@jameshfisher
Copy link

Steps to reproduce

{% link /assets/some_asset.png | absolute_url %}

Expected behavior

It embeds an absolute link to /assets/some_asset.png.

Actual behavior

Liquid Exception: Could not find document '/assets/some_asset.png | absolute_url' in tag 'link'. Make sure the document exists and the path is correct. in /_layouts/default.html
...error:
             Error: Could not find document '/assets/some_asset.png | absolute_url' in tag 'link'. Make sure the document exists and the path is correct.
             Error: Run jekyll build --trace for more information.
@DirtyF
Copy link
Member

DirtyF commented Nov 5, 2017

Duplicate of #5682

@DirtyF DirtyF marked this as a duplicate of #5682 Nov 5, 2017
@ashmaroli
Copy link
Member

@jameshfisher As mentioned in our docs for this filter, one cannot use liquid filters with this tag (as of current releases.)

@ashmaroli
Copy link
Member

ashmaroli commented Nov 6, 2017

Workaround

Simply capture the path before-hand using the link tag and then proceed to using Jekyll's URL Filters

{% capture page_link %}{% link assets/some_asset.png %}{% endcapture %}
{{ page_link | absolute_url }}

Notes:

  • Variables created through {% capture %} are always strings.
  • link is a sensitive tag. It'll abort processing the site if the requested file doesn't exist.
  • you cannot link to a document in a collection with output: false

@jekyll jekyll locked and limited conversation to collaborators Jul 12, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

5 participants