{% assign lvl = page.url | append: 'X' | split: '/' | size %} {% capture relative %}{% for i in (3..lvl) %}../{% endfor %}{% endcapture %} {{ content }}