Use server-side redirects instead of alias files for better experience. (#3799)

(cherry picked from commit 22f520809f)
This commit is contained in:
Martin Taillefer 2019-03-20 09:38:18 -07:00 committed by mtail
parent 942c4e66d7
commit 554e6ae904
4 changed files with 22 additions and 9 deletions

View File

@ -16,7 +16,7 @@ build:
@$(docker) scripts/build_site.sh
gen: build
@$(docker) scripts/gen_site.sh "" -minify -no_aliases
@$(docker) scripts/gen_site.sh "" -minify
opt:
@$(docker) scripts/opt_site.sh

View File

@ -14,6 +14,9 @@ buildFuture = true
ignoreFiles = [ "OWNERS" ]
staticDir = ["static", "generated"]
# we use Netlify server-side redirects instead of generated aliases
disableAliases = true
# MARKDOWN
## Configuration for BlackFriday markdown parser: https://github.com/russross/blackfriday
[blackfriday]
@ -25,12 +28,21 @@ staticDir = ["static", "generated"]
extensions = [""]
[outputs]
home = ["HTML", "RSS"]
home = ["HTML", "RSS", "REDIR"]
section = ["HTML"]
[mediaTypes]
[mediaTypes."text/netlify"]
delimiter = ""
[outputFormats]
[outputFormats.RSS]
baseName = "feed"
[outputFormats.REDIR]
mediatype = "text/netlify"
baseName = "_redirects"
isPlainText = true
notAlternative = true
[related]
# Only include matches with rank >= threshold. This is a normalized rank between 0 and 100.

View File

@ -21,4 +21,11 @@ https://istio.netlify.com/* https://istio.io/:splat 301!
/ /zh 302 Language=zh
# Redirect for the helm charts
/charts/ https://gcsweb.istio.io/gcs/istio-release/releases/1.1.3/charts/ 301
/charts/ https://gcsweb.istio.io/gcs/istio-release/releases/{{ .Site.Data.args.full_version }}/charts/ 301
# Redirects for all aliases
{{- range $p := .Site.Pages -}}
{{- range .Aliases }}
{{ . | printf "%-35s" }} {{ $p.RelPermalink }}
{{- end -}}
{{- end }}

View File

@ -3,12 +3,6 @@ set -e
hugo version
if [[ "$3" == "-no_aliases" ]]
then
HUGO_DISABLEALIASES=true
export HUGO_DISABLEALIASES
fi
if [[ "$2" == "-no_minify" ]]
then
hugo --baseURL "$1"