Create anchor links in URL that includes trailing slashes

512 Views Asked by At

I have a react app (react hooks) using strapi and gatsby. The URLs look like http://localhost:8000/en/. Note at the end of the link is a trailing slash.

A few navbar links should scroll to specific sections on the homepage using anchor links. Due to the trailing slash the app would understand the anchor link as a new site which would then redirect to a 404 page.

Example:

http://localhost:8000/en/#section1/

even when hardcoding the link as /en#section1/ the slash would still be set between /en and #section1. This would have the same result => http://localhost:8000/en/#section1

Is it possible to create an anchor nav in an app that has trailing slashes without actually removing the trailing slashes?

0

There are 0 best solutions below