Skip to content

Commit

Permalink
Merge pull request #90 from s-makin/redirects
Browse files Browse the repository at this point in the history
Add Rediraffe support
  • Loading branch information
bryceharrington authored Dec 5, 2024
2 parents 10d21a1 + 4566cd8 commit 4f87c7b
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 1 deletion.
23 changes: 22 additions & 1 deletion contributing/submit-contribution.rst
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,28 @@ You can run:
make linkcheck
To perform a full spelling and link check. You can also run ``make`` by itself
to see a list of all the possible ``make`` targets.
to see a list of all the possible ``make`` targets.

Check if you need redirects
===========================

If you rename, move or delete an existing file, a corresponding redirect must
be created to ensure users don't run into 404 errors when clicking links in the
published documentation.

To set up a redirect, add a line to the end of the `redirects.txt` file in the
root directory, in the following format:

```
redirect/path/from/ redirect/path/to/
```

Note that since we use `dirhtml` to build, the built documentation is in the
format `path/to/file/index.html` where `file` corresponds to the file name
you are redirecting. This means that you only need a trailing slash at the end
of the file name, without the file extension. See the
`Sphinx Rediraffe docs <https://sphinxext-rediraffe.readthedocs.io/en/latest/>`_
for more guidance, or reach out to us for help.

Manual testing
==============
Expand Down
6 changes: 6 additions & 0 deletions custom_conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,7 @@
'myst_parser',
'sphinxcontrib.jquery',
'sphinxcontrib.mermaid',
'sphinxext.rediraffe',
# 'canonical.youtube-links',
# 'canonical.related-links',
# 'canonical.custom-rst-roles',
Expand All @@ -183,8 +184,13 @@
# sphinxext-opengraph
custom_required_modules = [
'sphinxcontrib-mermaid',
'sphinxext-rediraffe',
]

# Add redirects, so they can be updated here to land with docs being moved
rediraffe_branch = "main"
rediraffe_redirects = "redirects.txt"

# Add files or directories that should be excluded from processing.
custom_excludes = [
'cheatsheets/',
Expand Down
16 changes: 16 additions & 0 deletions redirects.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# The redirects.txt file stores all the redirects for the published docs
# If you change a filename, move or delete a file, you need a redirect here.
# - Comment lines start with a hash (#) and are ignored
# - Each redirect should appear on its own line

# We are using the dirhtml builder, so files are treated as directories:
# - A file is built like `filename/index.html`, not `filename.html`
# - *Do* include a trailing slash at the end of the path
# - *Do not* include a file extension or you'll get errors
# - Paths don't need a slash in front of them

# Example:
# redirect/from/file/ redirect/to/file/

explanation/intro-to/ explanation/introduction-to/

0 comments on commit 4f87c7b

Please sign in to comment.