From f9056d80d4d76415bb707aa322138bd6ba331465 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dani=C3=ABl=20van=20de=20Giessen?= Date: Wed, 23 Apr 2025 14:22:28 +0200 Subject: [PATCH] fix: links to fragment on same page should not be made portable --- layouts/_default/_markup/render-link.html | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/layouts/_default/_markup/render-link.html b/layouts/_default/_markup/render-link.html index 464fa1a..288d81c 100644 --- a/layouts/_default/_markup/render-link.html +++ b/layouts/_default/_markup/render-link.html @@ -7,7 +7,8 @@ {{- define "portable-link" -}} {{- $destination := .Destination }} {{- $isRemote := or (in .Destination ":") (strings.HasPrefix .Destination "//") }} - {{- if not $isRemote }} + {{- $isFragment := strings.HasPrefix .Destination "#" }} + {{- if and (not $isRemote) (not $isFragment) }} {{- $url := urls.Parse .Destination }} {{- $path := strings.TrimSuffix "/_index.md" $url.Path }} {{- $path = strings.TrimSuffix "/_index" $path }}