fix: PermaLink to RelPermalink

This commit is contained in:
Junyi Hou 2024-04-09 19:33:28 +08:00
parent f774d2689d
commit 9f33764cff
7 changed files with 18 additions and 20 deletions

View File

@ -9,7 +9,7 @@
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"> <rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
<channel> <channel>
<title>{{ if eq .Title .Site.Title }}{{ .Site.Title }}{{ else }}{{ with .Title }}{{.}} on {{ end }}{{ .Site.Title }}{{ end }}</title> <title>{{ if eq .Title .Site.Title }}{{ .Site.Title }}{{ else }}{{ with .Title }}{{.}} on {{ end }}{{ .Site.Title }}{{ end }}</title>
<link>{{ .Permalink }}</link> <link>{{ .RelPermalink }}</link>
<description>{{ .Site.Title }}{{ if ne .Title .Site.Title }}{{ with .Title }} ({{.}}){{ end }}{{ end }}</description> <description>{{ .Site.Title }}{{ if ne .Title .Site.Title }}{{ with .Title }} ({{.}}){{ end }}{{ end }}</description>
<generator>Hugo -- gohugo.io</generator>{{ with .Site.LanguageCode }} <generator>Hugo -- gohugo.io</generator>{{ with .Site.LanguageCode }}
<language>{{.}}</language>{{end}}{{ with .Site.Author.email }} <language>{{.}}</language>{{end}}{{ with .Site.Author.email }}
@ -18,15 +18,15 @@
<copyright>{{.}}</copyright>{{end}}{{ if not .Date.IsZero }} <copyright>{{.}}</copyright>{{end}}{{ if not .Date.IsZero }}
<lastBuildDate>{{ .Date.Format "Mon, 02 Jan 2006 15:04:05 -0700" | safeHTML }}</lastBuildDate>{{ end }} <lastBuildDate>{{ .Date.Format "Mon, 02 Jan 2006 15:04:05 -0700" | safeHTML }}</lastBuildDate>{{ end }}
{{ with .OutputFormats.Get "RSS" }} {{ with .OutputFormats.Get "RSS" }}
{{ printf "<atom:link href=%q rel=\"self\" type=%q />" .Permalink .MediaType | safeHTML }} {{ printf "<atom:link href=%q rel=\"self\" type=%q />" .RelPermalink .MediaType | safeHTML }}
{{ end }} {{ end }}
{{ range $pages }} {{ range $pages }}
<item> <item>
<title>{{ .Title }}</title> <title>{{ .Title }}</title>
<link>{{ .Permalink }}</link> <link>{{ .RelPermalink }}</link>
<pubDate>{{ .Date.Format "Mon, 02 Jan 2006 15:04:05 -0700" | safeHTML }}</pubDate> <pubDate>{{ .Date.Format "Mon, 02 Jan 2006 15:04:05 -0700" | safeHTML }}</pubDate>
{{ with .Site.Author.email }}<author>{{.}}{{ with $.Site.Author.name }} ({{.}}){{end}}</author>{{end}} {{ with .Site.Author.email }}<author>{{.}}{{ with $.Site.Author.name }} ({{.}}){{end}}</author>{{end}}
<guid>{{ .Permalink }}</guid> <guid>{{ .RelPermalink }}</guid>
<description>{{ .Content | html }}</description> <description>{{ .Content | html }}</description>
</item> </item>
{{ end }} {{ end }}

View File

@ -2,21 +2,21 @@
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9" <urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"
xmlns:xhtml="http://www.w3.org/1999/xhtml"> xmlns:xhtml="http://www.w3.org/1999/xhtml">
{{ range where .Data.Pages "Params.hidden" "!=" true }} {{ range where .Data.Pages "Params.hidden" "!=" true }}
{{- if .Permalink -}} {{- if .RelPermalink -}}
<url> <url>
<loc>{{ .Permalink }}</loc>{{ if not .Lastmod.IsZero }} <loc>{{ .RelPermalink }}</loc>{{ if not .Lastmod.IsZero }}
<lastmod>{{ safeHTML ( .Lastmod.Format "2006-01-02T15:04:05-07:00" ) }}</lastmod>{{ end }}{{ with .Sitemap.ChangeFreq }} <lastmod>{{ safeHTML ( .Lastmod.Format "2006-01-02T15:04:05-07:00" ) }}</lastmod>{{ end }}{{ with .Sitemap.ChangeFreq }}
<changefreq>{{ . }}</changefreq>{{ end }}{{ if ge .Sitemap.Priority 0.0 }} <changefreq>{{ . }}</changefreq>{{ end }}{{ if ge .Sitemap.Priority 0.0 }}
<priority>{{ .Sitemap.Priority }}</priority>{{ end }}{{ if .IsTranslated }}{{ range .Translations }} <priority>{{ .Sitemap.Priority }}</priority>{{ end }}{{ if .IsTranslated }}{{ range .Translations }}
<xhtml:link <xhtml:link
rel="alternate" rel="alternate"
hreflang="{{ .Language.LanguageCode }}" hreflang="{{ .Language.LanguageCode }}"
href="{{ .Permalink }}" href="{{ .RelPermalink }}"
/>{{ end }} />{{ end }}
<xhtml:link <xhtml:link
rel="alternate" rel="alternate"
hreflang="{{ .Language.LanguageCode }}" hreflang="{{ .Language.LanguageCode }}"
href="{{ .Permalink }}" href="{{ .RelPermalink }}"
/>{{ end }} />{{ end }}
</url> </url>
{{- end -}} {{- end -}}

View File

@ -16,7 +16,7 @@
{{ end }} {{ end }}
{{ with .OutputFormats.Get "rss" -}} {{ with .OutputFormats.Get "rss" -}}
{{ printf `<link rel="%s" type="%s" href="%s" title="%s" />` .Rel .MediaType.Type .Permalink $.Site.Title | safeHTML }} {{ printf `<link rel="%s" type="%s" href="%s" title="%s" />` .Rel .MediaType.Type .RelPermalink $.Site.Title | safeHTML }}
{{ end -}} {{ end -}}
{{ partial "favicons.html" . }} {{ partial "favicons.html" . }}
@ -56,8 +56,6 @@
{{ $opts := dict "transpiler" "libsass" "targetPath" "css/style.css" }} {{ $opts := dict "transpiler" "libsass" "targetPath" "css/style.css" }}
{{ range site.Params.customCSS }} {{ range site.Params.customCSS }}
{{ with resources.Get . | toCSS $opts | minify | fingerprint }} {{ with resources.Get . | toCSS $opts | minify | fingerprint }}
<link rel="stylesheet" href="{{ .RelPermalink }}" integrity="{{ .Data.Integrity }}" crossorigin="anonymous"> <link rel="stylesheet" href="{{ .RelPermalink }}" integrity="{{ .Data.Integrity }}" crossorigin="anonymous">

View File

@ -9,7 +9,7 @@
{{ if eq .Lang $pageLang }} {{ if eq .Lang $pageLang }}
<li>{{ .Language.LanguageName }}</li> <li>{{ .Language.LanguageName }}</li>
{{ else }} {{ else }}
<li><a href="{{ .Permalink }}">{{ .Language.LanguageName }}</a></li> <li><a href="{{ .RelPermalink }}">{{ .Language.LanguageName }}</a></li>
{{ end }} {{ end }}
{{ end }} {{ end }}
</ul> </ul>

View File

@ -18,7 +18,7 @@
</div> </div>
{{ end }} {{ end }}
<a class="post-hidden-url u-url" href="{{ .Permalink }}">{{ .Permalink }}</a> <a class="post-hidden-url u-url" href="{{ .RelPermalink }}">{{ .RelPermalink }}</a>
<a href="{{ .Site.BaseURL }}" class="p-name p-author post-hidden-author h-card" rel="me">{{ .Params.author | default .Site.Params.author }}</a> <a href="{{ .Site.BaseURL }}" class="p-name p-author post-hidden-author h-card" rel="me">{{ .Params.author | default .Site.Params.author }}</a>
@ -27,7 +27,7 @@
<ul class="post-categories"> <ul class="post-categories">
{{ range $cat_name := .Params.categories }} {{ range $cat_name := .Params.categories }}
{{ $cat := ($.Site.GetPage (printf "/categories/%s" $cat_name | urlize )) }} {{ $cat := ($.Site.GetPage (printf "/categories/%s" $cat_name | urlize )) }}
<li><a href="{{ $cat.Permalink }}">{{ $cat.Title | default $cat_name }}</a></li> <li><a href="{{ $cat.RelPermalink }}">{{ $cat.Title | default $cat_name }}</a></li>
{{ end }} {{ end }}
</ul> </ul>
{{ end }} {{ end }}
@ -35,7 +35,7 @@
<ul class="post-tags"> <ul class="post-tags">
{{ range $tag_name := .Params.tags }} {{ range $tag_name := .Params.tags }}
{{ $tag := ($.Site.GetPage (printf "/tags/%s" $tag_name | urlize )) }} {{ $tag := ($.Site.GetPage (printf "/tags/%s" $tag_name | urlize )) }}
<li><a href="{{ $tag.Permalink }}">#{{ $tag.Title | default $tag_name }}</a></li> <li><a href="{{ $tag.RelPermalink }}">#{{ $tag.Title | default $tag_name }}</a></li>
{{ end }} {{ end }}
</ul> </ul>
{{ end }} {{ end }}
@ -43,7 +43,7 @@
<ul class="post-authors"> <ul class="post-authors">
{{ range $author_name := .Params.authors }} {{ range $author_name := .Params.authors }}
{{ $author := ($.Site.GetPage (printf "/authors/%s" $author_name | urlize )) }} {{ $author := ($.Site.GetPage (printf "/authors/%s" $author_name | urlize )) }}
<li><a href="{{ $author.Permalink }}">@{{ $author_name }}</a></li> <li><a href="{{ $author.RelPermalink }}">@{{ $author_name }}</a></li>
{{ end }} {{ end }}
</ul> </ul>
{{ end }} {{ end }}

View File

@ -15,9 +15,9 @@
{{ $resource = $resource | resources.Fingerprint "sha256" }} {{ $resource = $resource | resources.Fingerprint "sha256" }}
{{ if eq .type "css" }} {{ if eq .type "css" }}
<link rel="stylesheet" href="{{ $resource.Permalink }}" integrity="{{ $resource.Data.Integrity }}"> <link rel="stylesheet" href="{{ $resource.RelPermalink }}" integrity="{{ $resource.Data.Integrity }}">
{{ else if eq .type "js" }} {{ else if eq .type "js" }}
<script src="{{ $resource.Permalink }}" type="text/javascript" charset="utf-8" integrity="{{ $resource.Data.Integrity }}"></script> <script src="{{ $resource.RelPermalink }}" type="text/javascript" charset="utf-8" integrity="{{ $resource.Data.Integrity }}"></script>
{{ end }} {{ end }}
<!-- For backward compatibility --> <!-- For backward compatibility -->
{{ else }} {{ else }}

View File

@ -27,11 +27,11 @@
{{ if .Site.Params.rssAsSocialIcon }} {{ if .Site.Params.rssAsSocialIcon }}
{{ with .Site.Home.OutputFormats.Get "rss" -}} {{ with .Site.Home.OutputFormats.Get "rss" -}}
<li> <li>
<a {{ printf "href=%q" .Permalink | safeHTMLAttr }} title="RSS" rel="me"> <a {{ printf "href=%q" .RelPermalink | safeHTMLAttr }} title="RSS" rel="me">
{{ partial "font-awesome.html" (dict "iconName" "rss" "custom" false) }} {{ partial "font-awesome.html" (dict "iconName" "rss" "custom" false) }}
</a> </a>
</li> </li>
{{ end -}} {{ end -}}
{{ end }} {{ end }}
</ul> </ul>