Relative URLs

What’s correct way to find the relative path to root - or even two pages (or resources)?

I feel lost. I’ve looked into RelPermalink, relURL and relref nothing seems to work as I’d expect. In the base layout this seems to work fine

<link rel="stylesheet" href="{{ "css/styles.css" | relURL }}" />

But when I try this in a partial

{{ with .context }}
    a={{ "." | relURL }}
    b={{ .RelPermalink }}
    c={{ .RelPermalink | relURL }}
    d={{ .Permalink | relURL }}
{{ end }}

It just never is relative to the .context.
Any pointers?


Checkout the .File variable:

Thanks for the pointer - but I don’t see how that helps with relative URLs?

It will help you with this.