<!--base to have relative path for offline navigation -->

{% assign base = '.' %}
{% assign depth = page.url | split: '/' | size | minus: 1 %}
{% if    page.permalink != null %}
  {% assign depth = depth | plus: 1 %}
{% endif %}
{% if    depth == 1 %}{% assign base = '.' %}
{% elsif depth == 2 %}{% assign base = '..' %}
{% elsif depth == 3 %}{% assign base = '../..' %}
{% elsif depth == 4 %}{% assign base = '../../..' %}
{% elsif depth == 5 %}{% assign base = '../../../..' %}
{% elsif depth == 6 %}{% assign base = '../../../../..' %}{% endif %}