Skip to content

Instantly share code, notes, and snippets.

@Ketrel
Last active October 11, 2023 12:17
Show Gist options
  • Save Ketrel/1f36fca6b4148f7263b3ee8fdb0923e7 to your computer and use it in GitHub Desktop.
Save Ketrel/1f36fca6b4148f7263b3ee8fdb0923e7 to your computer and use it in GitHub Desktop.
Relative url base for jekyll
{% assign relBase = '' %}
{% assign tempDepth = page.url | append: 'hackish-solution' | split: '/' | size | minus: 2 %}
{% for i in (1..tempDepth) %}
{% assign relBase = relBase | append: "../" %}
{% endfor %}
{% if relBase == '' %}
{% assign relBase = './' %}
{% endif %}
@Sakrecoer
Copy link

@agowa this is not a layout. put it in _includes and call it in your layout. https://jekyllrb.com/docs/includes/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment