Better handle redirect docs
Currently, we use this rule https://docs.gitlab.com/ee/development/doc_styleguide.html#changing-document-location and then we parse the text in gitlab-docs
using a regex. That means the the text must much with the one we're searching for otherwise redirects would fail.
Proposal
In the document to be moved to a new location, provide a yaml frontmatter which specifies the layout to be used and where to redirect:
---
layout: redirect
redirect_to: ../path_of_new_doc/relative_to_the_old_one.md
---
In this case, the redirect layout will be used and the the redirect_to
will be replace the text inside that layout. We'll need to edit the layout as well.
To make things easier, I can create a new raketask that will fill in the new document automatically based on the user input.
-
Run:
rake gitlab:docs:redirect doc/path/to/doc.md ../path_of_new_doc/relative_to_the_old_one.md
-
This will then replace the contents of
doc/path/to/doc.md
with:--- layout: redirect redirect_to: ../path_of_new_doc/relative_to_the_old_one.md --- This document was moved to [another location](../path_of_new_doc/relative_to_the_old_one.md).
Edited by Achilleas Pipinellis