Redirecting within website
Unanswered
Blanc de Hotot posted this in #help-forum
Blanc de HototOP
I'm trying to make a redirection when "blog" gets clicked. I've tried to look up but I'm not sure what I am doing wrong
37 Replies
@Blanc de Hotot I'm trying to make a redirection when "blog" gets clicked. I've tried to look up but I'm not sure what I am doing wrong
what are you trying to do? why are you using react-router-dom in next?
Blanc de HototOP
Trying to click "blog" and send the user to another page within the website (blog.js). react-router-dom is because I read online someone doing with it (just an attempt to do something)
@Blanc de Hotot Trying to click "blog" and send the user to another page within the website (blog.js). react-router-dom is because I read online someone doing with it (just an attempt to do something)
do you render "blog" like this?
<Link href='/blog'>Blog</Link>Blanc de HototOP
No, let me send you what it does
const navLinks = [
...
{
path: "/blog",
title: "Blog"
}
...Original message was deleted
try this and you don't need to use react-router-dom with next
Blanc de HototOP
Do I need to import blog?
no
Blanc de HototOP
export default function Home() {
return (
<main>
test
</main>
);
}this is blog.js
create the blog page at
/src/app/blog/page.jsBlanc de HototOP
ok
every page need to be named with
page.jsBlanc de HototOP
I worked :D
I was very close but then I tried random stuff. I thought the problem was with URL
I was very close but then I tried random stuff. I thought the problem was with URL
Thanks a lot
and one more simple thing
for the path, do we just need to put /folder?
If I had a file inside components (src/app/components) and I want to use something in blog (src/app/blog)
/blog would work?
Blanc de HototOP
yes, as an example
and I want to use it in src/app/components
sure, you can import it from
src/app/blog/page.jsBlanc de HototOP
Do I need the full path tho?
or can I do ./blog/page.js
wait, you want to import the page into a component inside
src/app/components?Blanc de HototOP
Yes, again this is just an example of how to use URLS
eg. if you want to make a page and the url is /hello, you have to create a file at
src/app/hello/page.tsxyou could create the component in
src/app/component and import it to the pageBlanc de HototOP
So all components can just go under the same folder
For all pages
yes, you can leave them inside
src/app/hello/ too if you wantsince next only look for
page.jsor
route.jsBlanc de HototOP
Awesome, thank you! I appreciate your help!