hugo-theme-relearn/layouts/partials/toBaseRelURL.hugo

8 lines
330 B
Text
Raw Normal View History

{{- $url := .RelPermalink }}
{{- $url = replaceRE "/[^/]*$" "" $url }}
{{- $home_url := .Site.Home.RelPermalink }}
{{- $home_url = replaceRE "/[^/]*$" "" $home_url }}
{{- $rel_url := strings.TrimPrefix $home_url $url }}
{{- $rel_url = replaceRE "/[^/]*" "/.." $rel_url }}
{{- $rel_url = trim $rel_url "/" }}
{{- return $rel_url }}