JuliaDocs / DocumenterTools.jl

Extra tools for setting up Documenter
Other
30 stars 19 forks source link

Add `generate_redirects` function to generate HTML redirects of Documenter sites #76

Open mortenpi opened 1 year ago

mortenpi commented 1 year ago

The use case I imagine here is where you want to move the docs from one domain to another (e.g. when you move the package from one GitHub org to another), but you want to keep the old URLs working(-ish).

The normal process is to just move the gh-pages to the new repo. With this function, you can replace the old site with redirects to the new site.

E.g. let's say you want to move from a github.com/personalusername/MyPackage.jl (docs hosted at https://personalusername.github.io/MyPackage.jl/) to github.com/CentralizedJuliaOrg/MyPackage.jl (with docs hosted at https://centralizedjulia.org/MyPackage.jl.

To do that, you can check out the gh-pages branch locally and run:

DocumenterTools.generate_redirects(
    src = "<path-to-current-gh-pages>",
    out = "...",
    rooturl = "https://centralizedjulia.org/MyPackage.jl",
)

The contents of out should be pushed to the old repository (i.e. personalusername), and then https://personalusername.github.io/MyPackage.jl/... should redirect to the new domain.

Currently builds on top of #75. Needs tests and docs.