How to redirect many pages #748
-
I'm trying to redirect a bunch of pages. additionalPages: [{
path: '/from/here.html',
filePath: path.resolve(__dirname, '../to/here.md'),
},
// ... many more pages
] V2 suggests I tried doing something like this, which seemed promising: import { createPage, PageOptions } from "@vuepress/core";
const option: PageOptions = {
path: "/from/here.html",
filePath: "/to/here.md",
};
const page = await createPage(app, option);
app.pages.push(page);
},
}; And importing it into my config through the |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
Your questioni is quite confusing me. What to you mean by redirect? When people are talking about redirect, (such as You probably may need to describe it as cloning if you are actually providing same content in mutiple pages. Also that will make same page availble in mutiple links (i.e., When you provide that config in V1, I believed you are creating a new Anyway, I think V2 is providing the right behavior. If you want a redirect, you may need to use a custom layout, providing you a blank page and redirect with the url you want later. Edited: If you are procceeding with a lot of urls, e.g.: changing a base to another, you probably need to config the server, to perform a 302 redirect with that url, it should not be set here. Provide a html blank page and redirect to another url using js should NOT be the correct solution I will mark it as solved, feel free to ask related question if you have problems achieving it with the way I mentioned. |
Beta Was this translation helpful? Give feedback.
Your questioni is quite confusing me. What to you mean by redirect? When people are talking about redirect, (such as
a
tob
), they probably want an unexistinga
, and navigating tob
automaticlly when visitinga
.You probably may need to describe it as cloning if you are actually providing same content in mutiple pages. Also that will make same page availble in mutiple links (i.e.,
a
has the exact content comparing withb
), but a limitation is page a and page b do not share the same state.When you provide that config in V1, I believed you are creating a new
/from/here.html
page, which it's content are using/to/here.md
, therefore you can visit/from/here.html
directly and see same content…