Anchor links not working on Sassafras in Chrome?

QuestionsCategory: Hello SassafrasAnchor links not working on Sassafras in Chrome?
Adam Dobay asked 4 years ago

Hi,

We’re running multiple sites on Sassafras and we simply love it. However, we’ve noticed a weird issue that we can’t find a solution for.

Anchor links don’t seem to work in Sassafras under Chrome.

We’ve noticed when we built a page where we set up a table of contents with a lot of anchor links: https://www.followthemoonrabbit.com/studio-ghibli-storytelling/

And here’s a random page from our other blog where you can see that clicking on the comments doesn’t take you to #comments: https://www.urban-eve.hu/2019/05/15/hat-magacska-meg-folyton-azt-a-micsodat-nyomkodja/

Here’s everything we’ve tried to narrow down the issue:

  • We’ve tested in Firefox and Edge and anchor links work for both.
  • We placed anchor links in other Genesis installs we have that don’t run on Sassafras and those links work in Chrome as well.
  • We tried going the h2 id=”xyz” route as well as the deprecated a name=”xyz” route. Neither work under Chrome.
  • We’ve tested on pre-Gutenberg and Gutenberg-based posts, and everything is running on the latest versions of WordPress and Sassafras 2.0.5.
  • Finally, we’ve talked to our host WPEngine, who looked at our error logs and potentially conflicting plugins and have not found anything.

So we’ve kind of exhausted everything. Since it works under other Genesis themes, we think there might be something in Sassafras that is preventing anchor links from working in Chrome.

I’d love to know your take on what this might be, because we’ve been staring at it for several hours now and have no idea what it might be.

Many thanks,
Adam

2 Answers
Jennifer Staff answered 4 years ago

Chrome is not a fan of anchor links. There is code you can add to the theme file to make it compatible with chrome browsers. Here is a link to a discussion about it, let me know if you need any help with this

https://stackoverflow.com/questions/38588346/anchor-a-tags-not-working-in-chrome-when-using

Adam Dobay replied 4 years ago

Hi Jennifer! Thanks for the quick reply! I also found this page previously but didn’t know I could use that code in the theme. Can I ask which of the theme files to place this in?
Thank you,
Adam

Adam Dobay replied 3 years ago

Hi Jennifer, I’m still struggling with this issue, can you please let me know which theme file I should put this code in? Thank you!

Jennifer Staff answered 3 years ago

You can add it to an exisiting JS file or create a new one.

Adam Dobay replied 3 years ago

Ah, okay, I didn’t realise that.
I tried adding the scripts on the page you linked to to global.js, but no change. I went through all of the code snippets offered on the stackxchange page.
Do you have any other ideas, please? :/