Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handling of local anchor links in the built in link render hook #12503

Open
bep opened this issue May 16, 2024 · 3 comments
Open

Handling of local anchor links in the built in link render hook #12503

bep opened this issue May 16, 2024 · 3 comments

Comments

@bep
Copy link
Member

bep commented May 16, 2024

In my head this

{{- $href = printf "%s#%s" .PageInner.RelPermalink $u.Fragment }}

Should only include the anchor part (e.g. #foo) and not the .RelPermalink to the current page. I'm not totally sure how the different browsers handle this, but I'm pretty sure there's a difference.

I noticed this surface on the forum, see https://discourse.gohugo.io/t/markdown-syntax-render/49835

/cc @jmooring

@bep bep added this to the v0.126.2 milestone May 16, 2024
@jmooring
Copy link
Member

With the current implementation, if a summary rendered on a list page contains a same-page link, the link will properly resolve to the containing page instead of doing nothing.

@bep
Copy link
Member Author

bep commented May 16, 2024

Yea, right, I didn't think about that ... I'll put it on my list to check for "browser behaviour". Anyhow, people are free to add their own template.

@bep bep self-assigned this May 16, 2024
@bep bep added the NotSure label May 16, 2024
@bep bep modified the milestones: v0.126.2, v0.127.0 May 16, 2024
@jmooring
Copy link
Member

While monitoring the Network tab of Chrome's dev tools, I see no difference between #foo and /this/page/#foo... meaning there's zero network activity either way. The same is true in Firefox.

There may be some other side effect that I'm not aware of, but this approach seems to be fine.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants