untra / polyglot

:abc: Multilingual and i18n support tool for Jekyll Blogs
https://polyglot.untra.io
MIT License
416 stars 59 forks source link

document filters: absolute_url and relative_url #70

Closed rriemann closed 3 years ago

rriemann commented 7 years ago

Hey, some jekyll themes use:

{{ "/docs/assets/" | relative_url }} => /myproject/docs/assets
{{ "/docs/assets/" | absolute_url }} => https://jekyllrb.com/myproject/docs/assets

Is this supported? It would be nice to have a remark on this in the docs.

untra commented 7 years ago

If used on a language page, both filters will then be relativized for that language. This is always the rule.

For example, used on a non-default french (fr) site, the content becomes:

    {{ "/docs/assets/" | relative_url }} => /myproject/fr/docs/assets
    {{ "/docs/assets/" | absolute_url }} => https://jekyllrb.com/myproject/fr/docs/assets

If you want tyo use these filters without the language relativizing, you can prepend a space to the url.

    {{ " /docs/assets/" | relative_url }} => /myproject/docs/assets
    {{ " /docs/assets/" | absolute_url }} => https://jekyllrb.com/myproject/docs/assets

I hope this helps!