Created
March 20, 2017 07:17
-
-
Save SetoAira/d07f98623052b1f7ba079055de21a8f0 to your computer and use it in GitHub Desktop.
Get relative path for jekyll.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{% 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