Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
Get relative path for jekyll.
{% assign dep = {{{{page.url | split:"/"}} | size }} %}{% assign dep = {{dep | minus:2 }} %}{% assign url_last1 = {{page.url | slice: -5, 5}} %}{% assign url_last2 = {{page.url | slice: -1, 1}} %}{% if url_last1 == '.html' or url_last2 == '/' %}{% assign dep = {{dep | plus:1 }} %}{% endif %}{% assign relative = '' %}{% if dep <= 0 %}{% assign relative = './' %}{% else %}{% for i in (1..dep) %}{% assign relative = {{relative | append:'../'}} %}{% endfor %}{% endif %}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment