Comments (4)
Hey @koraylinux I think it's pretty straightforward to do what you want:
from https://nextjs.org/docs/routing/introduction#dynamic-route-segments
At least for me, it just works out-of-the-box by moving the [slug].js file from pages/posts/[slug].js
to pages/[slug].js
... other than updating some of the links in the rest of the code.
from tailwind-nextjs-starter-blog.
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
from tailwind-nextjs-starter-blog.
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.
from tailwind-nextjs-starter-blog.
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.
from tailwind-nextjs-starter-blog.
Related Issues (20)
- Need help with importing images in mdx files. HOT 3
- Add asciinema player HOT 1
- how to set ` invisiable? HOT 2
- What happened to `scripts/compose.js`? HOT 2
- Is there a part of writing markdown files where I apply a different thumbnail to each file? HOT 2
- Add blog series support HOT 3
- problem detected in xml sitemap
- Expected component `DonutChart` to be defined HOT 1
- ListLayoutwithtags pagination HOT 3
- If summary is too long it will hide the entire blog HOT 1
- Is there a good way to display the changes to the post on the website in real time? HOT 2
- Bug Report: Swiper React Component Runtime Error in MDX HOT 2
- Navigation and Scrolling Issues in Responsive Blog Template HOT 1
- Error analytics umami HOT 1
- How do we style KBar? HOT 3
- TypeError: Cannot read properties of undefined (reading 'Client') HOT 1
- Limit on the number of keywords in search HOT 1
- [Feature Request] Customize slug with front matter HOT 1
- Enhanced User Authentication and Membership Section HOT 1
- update github slugger package to v 2.0 HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from tailwind-nextjs-starter-blog.