Skip to content

Commit

Permalink
Seo improve (HEIGE-PCloud#1128)
Browse files Browse the repository at this point in the history
* 1. Display page count for paginated titles
2. The canonical URL for pagination is the same as the page URL.

* 1. Removed microdata and unified use of JSON-LD.
2. Add alternateName field to webSite schema. That is an alternate site name
  used in Google search results.
3. Fix missing field in google rich result test.
4. Prioritize using the featured image in front matter as the article image in JSON-LD.

---------

Co-authored-by: HEIGE-PCloud <[email protected]>
  • Loading branch information
2 people authored and Jatin794 committed Dec 19, 2024
1 parent 614823f commit de79ec0
Show file tree
Hide file tree
Showing 38 changed files with 382 additions and 109 deletions.
3 changes: 3 additions & 0 deletions content/posts/theme-documentation-basics/index.en.md
Original file line number Diff line number Diff line change
Expand Up @@ -779,6 +779,9 @@ Please open the code block below to view the complete sample configuration :(far
image = ""
# thumbnail URL
thumbnailUrl = ""
# {{< version 0.4.1 >}}
# alternate site name in Google search result
alternateName = ["Hugo DoIt"]

# {{< version 0.2.0 >}} Analytics config
[params.analytics]
Expand Down
3 changes: 3 additions & 0 deletions content/posts/theme-documentation-basics/index.zh-cn.md
Original file line number Diff line number Diff line change
Expand Up @@ -783,6 +783,9 @@ optimizeImages = true
image = ""
# 缩略图 URL
thumbnailUrl = ""
# {{< version 0.4.1 >}}
# Google 搜索结果中网站备用名字
alternateName = ["Hugo DoIt"]

# {{< version 0.2.0 >}} 网站分析配置
[params.analytics]
Expand Down
4 changes: 4 additions & 0 deletions exampleSite/config/_default/params.toml
Original file line number Diff line number Diff line change
Expand Up @@ -557,6 +557,10 @@ srcsetLargeResizeMethod = "2000x webp Lanczos q75"
# thumbnail URL
# 缩略图 URL
thumbnailUrl = "/images/screenshot.png"
# Google 搜索结果中网站备用名字
# alternate site name in Google search result
# https://developers.google.com/search/docs/appearance/site-names#alternative
# alternateName = ["Hugo DoIt"]

# Analytics config
# 网站分析配置
Expand Down
8 changes: 7 additions & 1 deletion themes/DoIt/i18n/am.toml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Translations for English
# Translations for Amharic
# https://gohugo.io/content-management/multilingual/#translation-of-strings

# === baseof ==
Expand Down Expand Up @@ -252,3 +252,9 @@ other = "ተለውጧል"
[deleted]
other = "ተሰርዟል።"
# === shortcodes/version.html ===

[prefixPageNumber]
other = "ገጽ"

[suffixPageNumber]
other = " "
6 changes: 6 additions & 0 deletions themes/DoIt/i18n/ar.toml
Original file line number Diff line number Diff line change
Expand Up @@ -192,3 +192,9 @@ other = "تم تعديله"
[deleted]
other = "حُذف"
# === shortcodes/version.html ===

[prefixPageNumber]
other = " "

[suffixPageNumber]
other = "الصفحة"
6 changes: 6 additions & 0 deletions themes/DoIt/i18n/ca.toml
Original file line number Diff line number Diff line change
Expand Up @@ -192,3 +192,9 @@ other = "CANVIAT"
[deleted]
other = "SUPRIMIT"
# === shortcodes/version.html ===

[prefixPageNumber]
other = "Página"

[suffixPageNumber]
other = " "
6 changes: 6 additions & 0 deletions themes/DoIt/i18n/de.toml
Original file line number Diff line number Diff line change
Expand Up @@ -191,3 +191,9 @@ other = "GEÄNDERT"
[deleted]
other = "GELÖSCHT"
# === shortcodes/version.html ===

[prefixPageNumber]
other = "Seite"

[suffixPageNumber]
other = " "
6 changes: 6 additions & 0 deletions themes/DoIt/i18n/el.toml
Original file line number Diff line number Diff line change
Expand Up @@ -196,3 +196,9 @@ other = "ΑΛΛΑΓΜΕΝΟ"
[deleted]
other = "ΔΙΑΓΡΑΜΜΕΝΟ"
# === shortcodes/version.html ===

[prefixPageNumber]
other = "Σελίδα"

[suffixPageNumber]
other = " "
6 changes: 6 additions & 0 deletions themes/DoIt/i18n/en.toml
Original file line number Diff line number Diff line change
Expand Up @@ -252,3 +252,9 @@ other = "CHANGED"
[deleted]
other = "DELETED"
# === shortcodes/version.html ===

[prefixPageNumber]
other = "Page"

[suffixPageNumber]
other = " "
6 changes: 6 additions & 0 deletions themes/DoIt/i18n/es.toml
Original file line number Diff line number Diff line change
Expand Up @@ -235,3 +235,9 @@ other = "MODIFICADO"
[deleted]
other = "ELIMINADO"
# === shortcodes/version.html ===

[prefixPageNumber]
other = "Página"

[suffixPageNumber]
other = " "
7 changes: 7 additions & 0 deletions themes/DoIt/i18n/fr.toml
Original file line number Diff line number Diff line change
Expand Up @@ -256,3 +256,10 @@ other = "CHANGÉ"
[deleted]
other = "EFFACÉ"
# === shortcodes/version.html ===

[prefixPageNumber]
other = "Page"

[suffixPageNumber]
other = " "

8 changes: 7 additions & 1 deletion themes/DoIt/i18n/hi.toml
Original file line number Diff line number Diff line change
Expand Up @@ -191,4 +191,10 @@ other = "बदला हुआ"

[deleted]
other = "हटाए गए"
# === shortcodes/version.html ===
# === shortcodes/version.html ===

[prefixPageNumber]
other = "पृष्ठ"

[suffixPageNumber]
other = " "
6 changes: 6 additions & 0 deletions themes/DoIt/i18n/id.toml
Original file line number Diff line number Diff line change
Expand Up @@ -192,3 +192,9 @@ other = "BERUBAH"
[deleted]
other = "DIHAPUS"
# === shortcodes/version.html ===

[prefixPageNumber]
other = "Halaman"

[suffixPageNumber]
other = " "
6 changes: 6 additions & 0 deletions themes/DoIt/i18n/it.toml
Original file line number Diff line number Diff line change
Expand Up @@ -191,3 +191,9 @@ other = "CAMBIATO"
[deleted]
other = "CANCELLATO"
# === shortcodes/version.html ===

[prefixPageNumber]
other = "Pagina"

[suffixPageNumber]
other = " "
6 changes: 6 additions & 0 deletions themes/DoIt/i18n/ko.toml
Original file line number Diff line number Diff line change
Expand Up @@ -218,3 +218,9 @@ other = "변경"
[deleted]
other = "삭제"
# === shortcodes/version.html ===

[prefixPageNumber]
other = " "

[suffixPageNumber]
other = "페이지"
6 changes: 6 additions & 0 deletions themes/DoIt/i18n/pl.toml
Original file line number Diff line number Diff line change
Expand Up @@ -191,3 +191,9 @@ other = "Zmieniono"
[deleted]
other = "Usunięte"
# === shortcodes/version.html ===

[prefixPageNumber]
other = "Strona"

[suffixPageNumber]
other = " "
6 changes: 6 additions & 0 deletions themes/DoIt/i18n/pt-BR.toml
Original file line number Diff line number Diff line change
Expand Up @@ -251,3 +251,9 @@ other = "ALTERADO"
[deleted]
other = "EXCLUÍDO"
# === shortcodes/version.html ===

[prefixPageNumber]
other = "Página"

[suffixPageNumber]
other = " "
6 changes: 6 additions & 0 deletions themes/DoIt/i18n/pt-PT.toml
Original file line number Diff line number Diff line change
Expand Up @@ -251,3 +251,9 @@ other = "ALTERADO"
[deleted]
other = "EXCLUÍDO"
# === shortcodes/version.html ===

[prefixPageNumber]
other = "Página"

[suffixPageNumber]
other = " "
6 changes: 6 additions & 0 deletions themes/DoIt/i18n/ro.toml
Original file line number Diff line number Diff line change
Expand Up @@ -191,3 +191,9 @@ other = "SCHIMBAT"
[deleted]
other = "ȘTERS"
# === shortcodes/version.html ===

[prefixPageNumber]
other = "Pagină"

[suffixPageNumber]
other = " "
6 changes: 6 additions & 0 deletions themes/DoIt/i18n/ru.toml
Original file line number Diff line number Diff line change
Expand Up @@ -252,3 +252,9 @@ other = "ИЗМЕНЕН"
[deleted]
other = "УДАЛЕН"
# === shortcodes/version.html ===

[prefixPageNumber]
other = "Стр."

[suffixPageNumber]
other = " "
6 changes: 6 additions & 0 deletions themes/DoIt/i18n/sr.toml
Original file line number Diff line number Diff line change
Expand Up @@ -191,3 +191,9 @@ other = "ПРОМЕЊЕНО"
[deleted]
other = "ОБРИСАНО"
# === shortcodes/version.html ===

[prefixPageNumber]
other = "Страница"

[suffixPageNumber]
other = " "
8 changes: 7 additions & 1 deletion themes/DoIt/i18n/te.toml
Original file line number Diff line number Diff line change
Expand Up @@ -192,4 +192,10 @@ other = "మార్చబడింది"

[deleted]
other = "తొలగించిన"
# === shortcodes/version.html ===
# === shortcodes/version.html ===

[prefixPageNumber]
other = "పుట"

[suffixPageNumber]
other = " "
6 changes: 6 additions & 0 deletions themes/DoIt/i18n/th.toml
Original file line number Diff line number Diff line change
Expand Up @@ -192,3 +192,9 @@ other = "เปลี่ยนแปลง"
[deleted]
other = "ลบ"
# === shortcodes/version.html ===

[prefixPageNumber]
other = "หน้า"

[suffixPageNumber]
other = " "
8 changes: 7 additions & 1 deletion themes/DoIt/i18n/ti.toml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Translations for English
# Translations for Tigrinya
# https://gohugo.io/content-management/multilingual/#translation-of-strings

# === baseof ==
Expand Down Expand Up @@ -252,3 +252,9 @@ other = "ተለዊጡ"
[deleted]
other = "ተደምሲሱ"
# === shortcodes/version.html ===

[prefixPageNumber]
other = "ስራሕ"

[suffixPageNumber]
other = " "
6 changes: 6 additions & 0 deletions themes/DoIt/i18n/tr.toml
Original file line number Diff line number Diff line change
Expand Up @@ -253,3 +253,9 @@ other = "DEĞİŞTİRİLDİ"
[deleted]
other = "SİLİNDİ"
# === shortcodes/version.html ===

[prefixPageNumber]
other = "Sayfa"

[suffixPageNumber]
other = " "
6 changes: 6 additions & 0 deletions themes/DoIt/i18n/uk.toml
Original file line number Diff line number Diff line change
Expand Up @@ -193,3 +193,9 @@ other = "ЗМІНЕНИЙ"
[deleted]
other = "ВИДАЛЕНИЙ"
# === shortcodes/version.html ===

[prefixPageNumber]
other = "Cторінка"

[suffixPageNumber]
other = " "
6 changes: 6 additions & 0 deletions themes/DoIt/i18n/vi.toml
Original file line number Diff line number Diff line change
Expand Up @@ -252,3 +252,9 @@ other = "THAY ĐỔI"
[deleted]
other = "XOÁ"
# === shortcodes/version.html ===

[prefixPageNumber]
other = "Trang"

[suffixPageNumber]
other = " "
5 changes: 5 additions & 0 deletions themes/DoIt/i18n/zh-CN.toml
Original file line number Diff line number Diff line change
Expand Up @@ -251,3 +251,8 @@ other = "更改"
other = "删除"
# === shortcodes/version.html ===

[prefixPageNumber]
other = ""

[suffixPageNumber]
other = ""
6 changes: 6 additions & 0 deletions themes/DoIt/i18n/zh-TW.toml
Original file line number Diff line number Diff line change
Expand Up @@ -189,3 +189,9 @@ other = "更改"
[deleted]
other = "刪除"
# === shortcodes/version.html ===

[prefixPageNumber]
other = ""

[suffixPageNumber]
other = ""
8 changes: 8 additions & 0 deletions themes/DoIt/layouts/_default/baseof.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,14 @@
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="robots" content="noodp" />

{{- /* Paginate */ -}}
{{- /* Paginate in here, To solve the problem of the canonical URL being the same in the pagination */ -}}
{{- /* see more https://github.com/gohugoio/hugo/issues/4507 */ -}}
{{- /* see more https://discourse.gohugo.io/t/control-pagination-and-page-collections-from-baseof-html/37643/8 */ -}}
{{- /* see more https://discourse.gohugo.io/t/determine-if-current-page-is-result-of-pagination/37494/4 */ -}}
{{- partial "head/paginator.html" . -}}

<title>
{{- block "title" . }}{{ .Site.Title }}{{ end -}}
</title>
Expand Down
16 changes: 8 additions & 8 deletions themes/DoIt/layouts/_default/section.html
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
{{- define "title" }}
{{- .Params.Title | default (T .Section) | default .Section | dict "Some" | T "allSome" }} - {{ .Site.Title -}}
{{- if (gt .Paginator.PageNumber 1) -}}
{{ $pageNumber := printf "%v %v %v" (T "prefixPageNumber" ) .Paginator.PageNumber (T "suffixPageNumber" ) }}
{{- .Params.Title | default (T .Section) | default .Section | dict "Some" | T "allSome" }} {{ $pageNumber }} - {{ .Site.Title -}}
{{- else -}}
{{- .Params.Title | default (T .Section) | default .Section | dict "Some" | T "allSome" }} - {{ .Site.Title -}}
{{- end -}}
{{- end -}}

{{- define "content" -}}
Expand All @@ -10,15 +15,10 @@ <h2 class="single-title animate__animated animate__pulse animate__faster">
</h2>

{{- /* Paginate */ -}}
{{- /* Paginate is first call on baseof.html */ -}}
{{- if .Pages -}}
{{- $pages := .Pages.GroupByDate "2006" -}}
{{- with .Site.Params.section.paginate | default .Site.Params.paginate -}}
{{- $pages = $.Paginate $pages . -}}
{{- else -}}
{{- $pages = .Paginate $pages -}}
{{- end -}}
{{- partial "recentlyUpdated.html" . -}}
{{- range $pages.PageGroups -}}
{{- range .Paginator.PageGroups -}}
<h3 class="group-title">{{ .Key }}</h3>
{{- range .Pages -}}
<article class="archive-item">
Expand Down
4 changes: 2 additions & 2 deletions themes/DoIt/layouts/_default/summary.html
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{{- $params := .Params | merge .Site.Params.page -}}

<article class="single summary" itemscope itemtype="http://schema.org/Article">
<article class="single summary">
{{- /* Featured image */ -}}
{{- $image := $params.featuredImagePreview | default $params.featuredImage -}}
{{- with $image -}}
Expand All @@ -12,7 +12,7 @@
{{- end -}}

{{- /* Title */ -}}
<h1 class="single-title" itemprop="name headline">
<h1 class="single-title">
<a href="{{ .RelPermalink }}">{{ .Title }}</a>
</h1>

Expand Down
Loading

0 comments on commit de79ec0

Please sign in to comment.