{{ range $old, $new := hugo.Data.redirects }} {{ with site.GetPage $new }} {{ $html := printf `
This page has moved to %s.
` (htmlEscape .Params.canonical) (htmlEscape .RelPermalink) (htmlEscape .RelPermalink) (htmlEscape .Title) (.RelPermalink | jsonify) }} {{ $resource := resources.FromString (printf "%sindex.html" (strings.TrimPrefix "/" $old)) $html }} {{ $resource.Publish }} {{ else }} {{ errorf "redirect %s points to missing page %s" $old $new }} {{ end }} {{ end }}