hugo-geo
hugo-geo copied to clipboard
Markdown anchor links don't work properly
Anchor links shouldn't open in a new tab. Should be able to press browser back/forward to navigate around previously clicked anchor links.
[Test](#sometest)
# sometest
Seems to be some conflict related to the css. If you take the body's height: 100% out, it can navigate back and forth off anchor links. Unfortunately doing so breaks the theme completely so there is something else conflicting somewhere.
Thanks for bringing that up. It's due a small jquery snippet that was supposed to add target="new"
attributes to any link that goes outside of your website. It also added it to all relative links as well. I've tested it out and I think I've fixed it now in d54e167
@alexurquhart Thanks for the quick investigation. However, I am still experiencing issues. d54e167 looks to only be addressing scenario where the relative links start with /
or .
. For my anchor links, they all start with #
.
As an example
# Blah blah
Here is some text
[Quick Start](#quick-start)
Blah blah blah
Blah blah blah
Blah blah blah
Blah blah blah
# Quick Start
hi hi hi
Edit: Ya, on my end, I added an additional href[0] !== "#"
to your fix, but the issue I mentioned still persists. I can get linked to the anchor link, but I can't click back to bring me back. Stripping the css restores functionality though so I still suspect it's something in there.
Thanks for the clarification, I updated it again and tested it with links that start with #. a4c53c1
They navigate to the anchors within the same page correctly going forward, but somehow browser back still can't bring them back to before anchor navigation.
Looking into it further it's the .container-fluid
div that acts as a wrapper for the entire layout, so the body element isn't the one that scrolls, it's the .content
div. This is also leading to minor issues with the mobile navigation as well.
To fix this the CSS and markup would need to be refactored a bit. I am working on the next iteration of the theme (on the v2 branch) that doesn't have this problem, but I'd still like to fix this at some point as well.
Thanks for all the hard work. I rather like your fantastic v1 theme so hope you'll find some time to fix this issue. It makes it a bit difficult for long tutorials without being able to anchor link chapters correctly. If there is anything you'd like help on feel free to let me know. Thanks.