Delete a Page
In Nuxt, pages are automatically generated from the app/pages/ folder. This means deleting a page is as simple as removing its file, and Nuxt will automatically remove the
route for it.
There’s no CLI command to delete a page — it’s done manually. However, there are a few important steps to follow to ensure your project remains clean.
Removing a Page File:
-
Delete the Page File:
- Go to your project's
pagesfolder. - Find the
.vuefile (or folder with anindex.vueinside) corresponding to the page you want to remove. - Delete that file or folder.
- Go to your project's
-
Remove Page Links:
- Search your project for
<NuxtLink>ornavigateTo()calls that link to the deleted page. - Remove or update those links so they don’t point to a missing route.
-
Example link to remove:
<NuxtLink to="/about">About Us</NuxtLink>
- Search your project for
-
Remove Dynamic Route References (if applicable):
- If the deleted page was a dynamic route (e.g.,
app/pages/blog/[id].vue), make sure you remove any code that tries to navigate to it or fetch its data.
- If the deleted page was a dynamic route (e.g.,
-
Clean Up Sidebar/Menu:
- If you had a menu or sidebar entry for this page, update your navigation configuration file or component to remove the link.
Warning:
If your page was linked from the sidebar or header menu, leaving those links will cause a
404 Page Not Found error.