Next.js Discord

Discord Forum

how to get tag if I want to go to a section with tag not page

Unanswered
Thrianta posted this in #help-forum
Open in Discord
ThriantaOP
I'm trying to build portfolio website navigation bar and in my portfolio i have a single page with multiple section i want to go to a particular section with navbar and want to highlight that section in navbar . but with using usepathname im getting "/" . how i can fetch the section where I'm now . my URL looks like this "http://localhost:3000/#projects" and I want to get "#projects"

11 Replies

Greenish Elaenia
then you need to create a folder under /apps called /projects and put a page.tsx in it
your question is called "routing" in the nextjs docs
if you mean you want to jump to one specific section in the same page, like a table of contents does, then its not a routing issue
in the case you want to jump to a section, use "Link"
like this:
<Link href="#projects">projects</Link>
ThriantaOP
yes i want to jump to a specific section. I can do it also but don't know how to fetch the tag name where I'm now from url
so that i can highlight that on navbar
Greenish Elaenia
highlighting in navbar can be done w react components state
maybe try that see if it works for u
btw if u want url to jump to the section, u want scroll=false