Skip to content

Client-side redirects #4160

@Veetaha

Description

@Veetaha

Is your feature request related to a problem? Please describe.

I'm using Vitepress to document my Rust library called bon. I'm hosting it on Github Pages, which is quite a limited hosting provider, but it's a simple one and it's built into Github, so it's very convenient. Github Pages doesn't support server-side redirects, however, VitePress could just do redirects client-side.

I'm preparing a 2.0 release of my library. I'm organizing different versions of the docs under v1/ and v2/ path prefixes. However, I'd like to have a special prefix (e.g. latest/) that would forward to the latest version of the docs, such that I could use this link in my blog posts, for example. The version-specific URLs are used the doc-comments of my library.

Or.. ideally, prefix-less paths should forward to the latest version of the docs automatically. A similar thing is implemented on docs.rs (the default site that generates docs for Rust libraries):

I want to have the same behaviour with Vitepress where

Describe the solution you'd like

There could be client-side redirects config in Vitepress config.mts file. For example, an object with glob patterns:

{
     "/guide/*": "/v2/guide/${1}",
     "/reference/*": "/v2/reference/${1}"
}

(inspired by Cloudflare's routing rules)

Describe alternatives you've considered

Only workarounds:

Additional context

I'm weak at frontend, and especially Vue, but I used other similar frontend frameworks ~6 years ago at university. So I'm seeking for a simple solution to this problem that doesn't involve writing a lot of Vue code or moving to another static page hosting. I adore the current VitePress design and simplicity ❤️

Validations

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions