How To Create Redirect As Hugo Theme

Starting from version v1.12.0, Bissetii integrated the meta-tag with redirect capability into all pages. This allows anyone to perform page redirect easily without needing to move the documentation sources around.

The Page redirectURL

To enable page redirect, there are 2 steps to deal with:

Specify destination URL

You can specify your destination URL into redirectURL variable in your page’s front-matter parameter list. Here is an example using toml front-matter:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
+++
...

redirectURL = "https://example.com"

...

[menu.main]
parent = ""
name = "Target Page"
url = "https://example.com"
pre = "๐Ÿ’ "
weight = 1

...

+++

Bissetii also interprets relative URL (to your base URL) just in case you want to redirect the page to other relative pages.

Activate/Deactivate Redirect

To activate or deactivate the redirect mechanism, you can set the layout in your page’s front-matter. Here is an example using toml front-matter:

1
2
3
4
5
6
7
8
+++
...

redirectURL = "https://example.com"
layout = "redirect"

...
+++

Setting redirect will render that page to perform redirect meta page and the redirecting mechanism happens immediately (0 second).

Setting something else (default is single from Bissetii) will render that page as it is.

Hide From Main Menu

To hide from main menu, set parent inside [menu.main] field as "redirect". Bissetii will filter these pages away from menu building automatically.

Example:

1
2
3
4
5
[menu.main]
parent = "redirect"
# name = "Custom title"
pre = "๐Ÿšฅ"
weight = 1

Epilogue

That’s all for how to create redirect for existing pages when using Bissetii as Hugo theme module. If you have any questions, please feel free to raise your queries in our Issues Section.