-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Change Page's Publish Directory #29
Comments
Hi, it's slightly different with nextjs since it uses file-based routing - the posts in /pages/blog/[slug] are routed to https://url/blog/slug. If you want to change it posts instead of blog, that would be relatively simple since you can move [slug].js to posts folder instead of blog but it's more tricky for it to be at the root and would need quite a bit of modification to make it work. Alternatively, if you are porting from hugo, you can add a redirect from url/sample-page to url/blog/sample-page. The documentation covers it in detail - https://nextjs.org/docs/api-reference/next.config.js/redirects |
The problem is that Google already indexed my old blog posts so when the visitor try to open my new site it will show 404 error. That's why i wanted to move posts in root pages directory. I will search another solution on next.js community. I hope they have a solution for this. I also recommend you to make this modifications on your template since people who decided shifting to your theme would definitely search the same solution. Serving pages under /blog directory is not much practical. |
Hey @koraylinux I think it's pretty straightforward to do what you want: At least for me, it just works out-of-the-box by moving the [slug].js file from |
That's what redirects do - it redirects users from the original link to the new link without 404 errors. My old blog uses the url/year/month/day/slug format and I re-directed them to url/blog/slug page for the new one so there are no such errors. |
Hello. I have built my blog and it works great. There is one thing i want to do but i don't know how. My english is limited to search the issue. I could make this in hugo with a single permalinks parameter.
My blog posts publishing under /blog directory and when i called a page, it shows like https://url/blog/sample-page so i would like to change this like https://url/sample-page.
How do i do this? Any help would be appreciated.
The text was updated successfully, but these errors were encountered: