doing http redirect in hugo
By JIMz
Procedures
- determine folder structure ;
- add layout according to (1) ;
- add content file according to (1) ;
determine folder structure
e.g. all redirect files are put under :
/content/redirect
then the new layout file should be :
/layouts/redirect/single.html
where the filename single
is the default layout filename according to Hugo, for the type specified by the parent folder, in this case redirect
;
if there will be more than 1 type of redirect templates, also put it here and just avoid that single
keyword.
add layout
content of the layout file :
<HTML>
<meta
http-equiv="refresh"
content="0; url={{ .Params.redirect_url }}"
/>
redirecting to : {{ .Params.redirect_url }}
</HTML>
notes:
- the content line is optional ;
.Params.redirect_url
refers to the variableredirect_url
defined as front matter in those content files in/content/redirect
;
add content file
a sample content file here.
notes:
- the only required front matter is
redirect_url
; - if there are more than 1 layout under
/layouts/redirect
, match that filename here with the front mattertype
; i.e. :- if there is a 2nd type of redirect named
redirect_with_delay
:- layout filename :
redirect_with_delay.html
- content front matter to include :
type: redirect_with_delay
- layout filename :
- if there is a 2nd type of redirect named
---
title: verification redirect - LPIC-1
type: redirect
desc: LPIC-1 verification
redirect_url: https://people.lpi.org/m/LPI000012523
tags:
- redirect
- IT
- lpi
- LPIC
- certifications
- verify
---