Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Guide for the redirects generator #2416

Merged
merged 1 commit into from
Dec 27, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
54 changes: 54 additions & 0 deletions _scripts/redirects_generator/run-redirects-generator.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
This document explains how redirects generator works and how to run it.

Redirects generator consists of two scripts: redirect from generator and redirects generator.

## Redirect from generator

The redirect from generator checks if docs have the `redirect_from` parameter in the front matter. If one or more documents don't have this parameter, the script adds it to them.

### Run redirect from generator

1. In `_scripts/redirects_generator/redirect_from_generator.sh`, define the document or the folder with documents to generate the parameter for:
```sh
...
folder_path="{RELATIVE_PATH_TO_DOC_OR_FOLDER}"
```
If the specified folder has subfolders, the script with recursively update the docs in them.

2. In a terminal, run the script:
```shell
bash _scripts/redirects_generator/redirect_from_generator.sh
```
This returns the list of docs the parameter has been added to.

## Redirects generator

The redirects generator appends the current path of one or more docs to their front matter. This is usually useful when you need to move a bunch of docs to another location. You need to run the script *before* you move the docs.

### Run the redirects generator

1. In `_scripts/redirects_generator/redirects_generator.sh`, define the absolute path to the repo on your machine:
```text
...
root_directory="{ABSOLUTE_PATH_TO_REPO}"
...
```
It's needed to generate the redirects relative to the path of the repo.

2. In `_scripts/redirects_generator/redirects_generator.sh`, define the the folder with documents to generate redirects for:
```
...
folder_path="{RELATIVE_PATH_TO_DOC_OR_FOLDER}"
...
```

If the specified folder has subfolders, the script with recursively update the docs in them.

3. In a terminal, run the script:
```shell
bash _scripts/redirects_generator/redirects_generator.sh
```

This returns the list of docs the paths have been added to.

4. In the updated docs, move the path to the `redirect_from` parameter in the front matter.
Loading