WIP: Add nanoc-redirector
Make the redirect mechanism more clever, so that we can remove the old files and retain only the new ones.
Old redirect behavior
With the old redirect behavior, the old document would have a
redirect_to value redirecting to the new doc. That means that the old doc should be retained FOREVER.
New redirect behavior
There is a Nanoc gem (https://github.com/gjtorikian/nanoc-redirector) that can be used to redirect files.
With the new redirect behavior, the new document would have a
redirect_from value redirecting from the old doc(s). That means that the old doc could be removed from CE/EE and let Nanoc handle the redirects based on the
redirect_from frontmatter value(s):
redirect_from: - user/project/pages/index.md - user/group/page.md
For example, if this change would happen in CE, this frontmatter will generate two pages in the following destinations:
Limitations of the gem
--- redirect_from: - /ee/api/ ---
but we cannot use relative links and markdown, not even HTML files:
--- redirect_from: - ../api/README.md ---
There is one unmerged PR that we need in order to use this: https://github.com/gjtorikian/nanoc-redirector/pull/6, which I included in this MR.
To use this, we need to:
- Patch this and/or contribute to upstream so that we can use relative URLs.
Rename the already used
redirect_fromvariable (we use it for the disqus identifier comments) !513 (merged) and https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/31595
I basically copied the plugin in the
lib/ dir, so we don't have to use the gem.
I took the changes from https://github.com/gjtorikian/nanoc-redirector/pull/6 and I added some functionality to be able to use markdown in the redirect links. So far, we cannot use "real" relative URLs, but we can use the paths relative to
doc/. For example:
--- redirect_from: - user/project/pages/index.md ---
I created an MR in CE to test this https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/31797.