Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trial

Peter Mingione
11,588 Pointssub nav is not working as expected
When building Descendant routes, when I click one of the sub nav buttons on the courses page, the subnav in the url does not get replaced but added to
example ...
http://localhost:3000/courses/
http://localhost:3000/courses/html/
http://localhost:3000/courses/html/css/
http://localhost:3000/courses/html/css/javascript/
I am not sure why this is happening
2 Answers

Travis Alstrand
Treehouse Project ReviewerIn React Router v6, when using <Link to="something">
or navigate("something")
, that path is relative to the current location, not the root. So if you're currently at /courses/html
and you do:
<Link to="css">CSS</Link>
It will go to /courses/html/css
.
I'd recommend trying absolute paths To avoid appending and instead replace the path, make the to prop start with a slash, like:
<Link to="/courses/css">CSS</Link>
I hope this helps, if I'm way off here please let me know

Peter Mingione
11,588 PointsThanks Travis ... that works. But the video lesson says to use the relative path. I'm just wondering why Laura is saying to build the sub nav that way. Am I missing something?