feat(SEO): update SEO config (#393)

This commit is contained in:
Dillon 2020-05-29 11:11:21 +08:00 committed by GitHub
parent 2242e0c3c7
commit 89a526d693
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
21 changed files with 137 additions and 107 deletions

2
.github/FUNDING.yml vendored
View file

@ -1 +1 @@
custom: https://www.paypal.me/dillonzq custom: https://paypal.me/dillonzq

View file

Before

Width:  |  Height:  |  Size: 222 KiB

After

Width:  |  Height:  |  Size: 222 KiB

View file

Before

Width:  |  Height:  |  Size: 97 KiB

After

Width:  |  Height:  |  Size: 97 KiB

View file

Before

Width:  |  Height:  |  Size: 40 KiB

After

Width:  |  Height:  |  Size: 40 KiB

View file

Before

Width:  |  Height:  |  Size: 1.6 MiB

After

Width:  |  Height:  |  Size: 1.6 MiB

View file

Before

Width:  |  Height:  |  Size: 107 KiB

After

Width:  |  Height:  |  Size: 107 KiB

View file

Before

Width:  |  Height:  |  Size: 638 KiB

After

Width:  |  Height:  |  Size: 638 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 71 KiB

View file

@ -936,29 +936,17 @@ enableEmoji = true
# located in "assets/" 位于 "assets/" # located in "assets/" 位于 "assets/"
# Or 或者 # Or 或者
# someJavascript = "https://cdn.example.com/some.js" # someJavascript = "https://cdn.example.com/some.js"
# SEO config # Page SEO config
# SEO 配置 # 页面 SEO 配置
[params.page.seo] [params.page.seo]
# image URL
# 图片 URL
images = []
# Publisher info # Publisher info
# 出版者信息 # 出版者信息
[params.page.seo.publisher] [params.page.seo.publisher]
name = "xxxx" name = "xxxx"
[params.page.seo.publisher.logo] logoUrl = "/images/avatar.png"
url = "logo.png"
width = 127
height = 40
# Logo info
# Logo 信息
[params.page.seo.logo]
url = "logo.png"
width = 127
height = 40
# Image info
# 图片信息
[params.page.seo.image]
url = "cover.png"
width = 800
height = 600
# TypeIt config # TypeIt config
# TypeIt 配置 # TypeIt 配置
@ -985,6 +973,16 @@ enableEmoji = true
pinterest = "" pinterest = ""
baidu = "" baidu = ""
# Site SEO config
# 网站 SEO 配置
[params.seo]
# image URL
# 图片 URL
image = "/images/Apple-Devices-Preview.png"
# thumbnail URL
# 缩略图 URL
thumbnailUrl = "/images/screenshot.png"
# Analytics config # Analytics config
# 网站分析配置 # 网站分析配置
[params.analytics] [params.analytics]

View file

@ -21,7 +21,7 @@ math:
> >
> It is based on the original [LeaveIt Theme](https://github.com/liuzc/LeaveIt) and [KeepIt Theme](https://github.com/Fastbyte01/KeepIt). > It is based on the original [LeaveIt Theme](https://github.com/liuzc/LeaveIt) and [KeepIt Theme](https://github.com/Fastbyte01/KeepIt).
![Hugo Theme LoveIt](Apple-Devices-Preview.png "Hugo Theme LoveIt") ![Hugo Theme LoveIt](/images/Apple-Devices-Preview.png "Hugo Theme LoveIt")
### Features ### Features

View file

@ -26,7 +26,7 @@ Welcome to take the time to propose a translation by [:(fas fa-code-branch fa-fw
> >
> It is based on the original [LeaveIt Theme](https://github.com/liuzc/LeaveIt) and [KeepIt Theme](https://github.com/Fastbyte01/KeepIt). > It is based on the original [LeaveIt Theme](https://github.com/liuzc/LeaveIt) and [KeepIt Theme](https://github.com/Fastbyte01/KeepIt).
![Hugo Theme LoveIt](Apple-Devices-Preview.png "Hugo Theme LoveIt") ![Hugo Theme LoveIt](/images/Apple-Devices-Preview.png "Hugo Theme LoveIt")
### Features ### Features

View file

@ -21,7 +21,7 @@ math:
> >
> 它的原型基于 [LeaveIt 主题](https://github.com/liuzc/LeaveIt) 和 [KeepIt 主题](https://github.com/Fastbyte01/KeepIt)。 > 它的原型基于 [LeaveIt 主题](https://github.com/liuzc/LeaveIt) 和 [KeepIt 主题](https://github.com/Fastbyte01/KeepIt)。
![Hugo 主题 LoveIt](Apple-Devices-Preview.png "Hugo 主题 LoveIt") ![Hugo 主题 LoveIt](/images/Apple-Devices-Preview.png "Hugo 主题 LoveIt")
### 特性 ### 特性

View file

@ -573,25 +573,14 @@ Please open the code block below to view the complete sample configuration :(far
# located in "assets/" # located in "assets/"
# Or # Or
# someJavascript = "https://cdn.example.com/some.js" # someJavascript = "https://cdn.example.com/some.js"
# {{< version 0.2.0 >}} SEO config # {{< version 0.2.10 changed >}} Page SEO config
[params.page.seo] [params.page.seo]
# image URL
images = []
# Publisher info # Publisher info
[params.page.seo.publisher] [params.page.seo.publisher]
name = "xxxx" name = ""
[params.page.seo.publisher.logo] logoUrl = ""
url = "logo.png"
width = 127
height = 40
# Logo info
[params.page.seo.logo]
url = "logo.png"
width = 127
height = 40
# Image info
[params.page.seo.image]
url = "cover.png"
width = 800
height = 600
# {{< version 0.2.5 >}} TypeIt config # {{< version 0.2.5 >}} TypeIt config
[params.typeit] [params.typeit]
@ -612,6 +601,13 @@ Please open the code block below to view the complete sample configuration :(far
pinterest = "" pinterest = ""
baidu = "" baidu = ""
# {{< version 0.2.10 >}} Site SEO config
[params.seo]
# image URL
image = ""
# thumbnail URL
thumbnailUrl = ""
# {{< version 0.2.0 >}} Analytics config # {{< version 0.2.0 >}} Analytics config
[params.analytics] [params.analytics]
enable = false enable = false
@ -803,11 +799,7 @@ into `/static`. Theyre easily created via [https://realfavicongenerator.net/]
Customize `browserconfig.xml` and `site.webmanifest` to set theme-color and background-color. Customize `browserconfig.xml` and `site.webmanifest` to set theme-color and background-color.
### 3.3 Add Logo and Cover for SEO ### 3.3 Style Customization
Add a logo image (127x40) and a cover image (800x600) in the `static` directory.
### 3.4 Style Customization
{{< version 0.2.8 changed >}} {{< version 0.2.8 changed >}}

View file

@ -578,25 +578,14 @@ Please open the code block below to view the complete sample configuration :(far
# located in "assets/" # located in "assets/"
# Or # Or
# someJavascript = "https://cdn.example.com/some.js" # someJavascript = "https://cdn.example.com/some.js"
# {{< version 0.2.0 >}} SEO config # {{< version 0.2.10 changed >}} Page SEO config
[params.page.seo] [params.page.seo]
# image URL
images = []
# Publisher info # Publisher info
[params.page.seo.publisher] [params.page.seo.publisher]
name = "xxxx" name = ""
[params.page.seo.publisher.logo] logoUrl = ""
url = "logo.png"
width = 127
height = 40
# Logo info
[params.page.seo.logo]
url = "logo.png"
width = 127
height = 40
# Image info
[params.page.seo.image]
url = "cover.png"
width = 800
height = 600
# {{< version 0.2.5 >}} TypeIt config # {{< version 0.2.5 >}} TypeIt config
[params.typeit] [params.typeit]
@ -617,6 +606,13 @@ Please open the code block below to view the complete sample configuration :(far
pinterest = "" pinterest = ""
baidu = "" baidu = ""
# {{< version 0.2.10 >}} Site SEO config
[params.seo]
# image URL
image = ""
# thumbnail URL
thumbnailUrl = ""
# {{< version 0.2.0 >}} Analytics config # {{< version 0.2.0 >}} Analytics config
[params.analytics] [params.analytics]
enable = false enable = false
@ -808,11 +804,7 @@ into `/static`. Theyre easily created via [https://realfavicongenerator.net/]
Customize `browserconfig.xml` and `site.webmanifest` to set theme-color and background-color. Customize `browserconfig.xml` and `site.webmanifest` to set theme-color and background-color.
### 3.3 Add Logo and Cover for SEO ### 3.3 Style Customization
Add a logo image (127x40) and a cover image (800x600) in the `static` directory.
### 3.4 Style Customization
{{< version 0.2.8 changed >}} {{< version 0.2.8 changed >}}

View file

@ -576,25 +576,14 @@ hugo
# 位于 "assets/" # 位于 "assets/"
# 或者 # 或者
# someJavascript = "https://cdn.example.com/some.js" # someJavascript = "https://cdn.example.com/some.js"
# {{< version 0.2.0 >}} SEO config # {{< version 0.2.10 changed >}} 页面 SEO 配置
[params.page.seo] [params.page.seo]
# 图片 URL
images = []
# 出版者信息 # 出版者信息
[params.page.seo.publisher] [params.page.seo.publisher]
name = "xxxx" name = ""
[params.page.seo.publisher.logo] logoUrl = ""
url = "logo.png"
width = 127
height = 40
# Logo 信息
[params.page.seo.logo]
url = "logo.png"
width = 127
height = 40
# 图片信息
[params.page.seo.image]
url = "cover.png"
width = 800
height = 600
# {{< version 0.2.5 >}} TypeIt 配置 # {{< version 0.2.5 >}} TypeIt 配置
[params.typeit] [params.typeit]
@ -615,6 +604,13 @@ hugo
pinterest = "" pinterest = ""
baidu = "" baidu = ""
# {{< version 0.2.10 >}} 网站 SEO 配置
[params.seo]
# 图片 URL
image = ""
# 缩略图 URL
thumbnailUrl = ""
# {{< version 0.2.0 >}} 网站分析配置 # {{< version 0.2.0 >}} 网站分析配置
[params.analytics] [params.analytics]
enable = false enable = false
@ -807,11 +803,7 @@ hugo
可以自定义 `browserconfig.xml``site.webmanifest` 文件来设置 theme-color 和 background-color. 可以自定义 `browserconfig.xml``site.webmanifest` 文件来设置 theme-color 和 background-color.
### 3.3 增加网站 logo 和封面用于 SEO 优化 ### 3.3 自定义样式
`static` 目录增加一个 logo 图片 (127x40) 和一个封面图片 (800x600).
### 3.4 自定义样式
{{< version 0.2.8 changed >}} {{< version 0.2.8 changed >}}

View file

@ -124,6 +124,9 @@ library:
# located in "assets/" # located in "assets/"
# Or # Or
# someJS = "https://cdn.example.com/some.js" # someJS = "https://cdn.example.com/some.js"
seo:
images: []
# ...
--- ---
``` ```
@ -160,6 +163,7 @@ library:
* **share**: the same as the `params.page.share` part in the [site configuration](../theme-documentation-basics#site-configuration). * **share**: the same as the `params.page.share` part in the [site configuration](../theme-documentation-basics#site-configuration).
* **comment**: {{< version 0.2.0 changed >}} the same as the `params.page.comment` part in the [site configuration](../theme-documentation-basics#site-configuration). * **comment**: {{< version 0.2.0 changed >}} the same as the `params.page.comment` part in the [site configuration](../theme-documentation-basics#site-configuration).
* **library**: {{< version 0.2.7 >}} the same as the `params.page.library` part in the [site configuration](../theme-documentation-basics#site-configuration). * **library**: {{< version 0.2.7 >}} the same as the `params.page.library` part in the [site configuration](../theme-documentation-basics#site-configuration).
* **seo**: {{< version 0.2.10 >}} the same as the `params.page.seo` part in the [site configuration](../theme-documentation-basics#site-configuration).
{{< admonition tip >}} {{< admonition tip >}}
{{< version 0.2.10 >}} {{< version 0.2.10 >}}

View file

@ -129,6 +129,9 @@ library:
# located in "assets/" # located in "assets/"
# Or # Or
# someJS = "https://cdn.example.com/some.js" # someJS = "https://cdn.example.com/some.js"
seo:
images: []
# ...
--- ---
``` ```
@ -165,6 +168,7 @@ library:
* **share**: the same as the `params.page.share` part in the [site configuration](../theme-documentation-basics#site-configuration). * **share**: the same as the `params.page.share` part in the [site configuration](../theme-documentation-basics#site-configuration).
* **comment**: {{< version 0.2.0 changed >}} the same as the `params.page.comment` part in the [site configuration](../theme-documentation-basics#site-configuration). * **comment**: {{< version 0.2.0 changed >}} the same as the `params.page.comment` part in the [site configuration](../theme-documentation-basics#site-configuration).
* **library**: {{< version 0.2.7 >}} the same as the `params.page.library` part in the [site configuration](../theme-documentation-basics#site-configuration). * **library**: {{< version 0.2.7 >}} the same as the `params.page.library` part in the [site configuration](../theme-documentation-basics#site-configuration).
* **seo**: {{< version 0.2.10 >}} the same as the `params.page.seo` part in the [site configuration](../theme-documentation-basics#site-configuration).
{{< admonition tip >}} {{< admonition tip >}}
{{< version 0.2.10 >}} {{< version 0.2.10 >}}

View file

@ -123,6 +123,9 @@ library:
# 位于 "assets/" # 位于 "assets/"
# 或者 # 或者
# someJS = "https://cdn.example.com/some.js" # someJS = "https://cdn.example.com/some.js"
seo:
images: []
# ...
--- ---
``` ```
@ -159,6 +162,7 @@ library:
* **share**: 和 [网站配置](../theme-documentation-basics#site-configuration) 中的 `params.page.share` 部分相同. * **share**: 和 [网站配置](../theme-documentation-basics#site-configuration) 中的 `params.page.share` 部分相同.
* **comment**: {{< version 0.2.0 changed >}} 和 [网站配置](../theme-documentation-basics#site-configuration) 中的 `params.page.comment` 部分相同. * **comment**: {{< version 0.2.0 changed >}} 和 [网站配置](../theme-documentation-basics#site-configuration) 中的 `params.page.comment` 部分相同.
* **library**: {{< version 0.2.7 >}} 和 [网站配置](../theme-documentation-basics#site-configuration) 中的 `params.page.library` 部分相同. * **library**: {{< version 0.2.7 >}} 和 [网站配置](../theme-documentation-basics#site-configuration) 中的 `params.page.library` 部分相同.
* **seo**: {{< version 0.2.10 >}} 和 [网站配置](../theme-documentation-basics#site-configuration) 中的 `params.page.seo` 部分相同.
{{< admonition tip >}} {{< admonition tip >}}
{{< version 0.2.10 >}} {{< version 0.2.10 >}}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 40 KiB

View file

@ -35,11 +35,25 @@
{{- with .Site.Params.description -}} {{- with .Site.Params.description -}}
"description": {{ . | safeHTML }}, "description": {{ . | safeHTML }},
{{- end -}} {{- end -}}
{{- with $params.seo.image -}} {{- $image := .Site.Params.seo.image -}}
"image": "{{ .url | absURL }}", {{- with dict "Path" $image "Resources" .Resources | partial "function/resource.html" -}}
"image": {
"@type": "ImageObject",
"url": "{{ .Permalink }}",
"width": {{ .Width }},
"height": {{ .Height }}
},
{{- else -}}
{{- with $image -}}
"image": "{{ . | absURL }}",
{{- end -}}
{{- end -}} {{- end -}}
{{- with $params.seo.logo -}} {{- with .Site.Params.seo.thumbnailUrl -}}
"thumbnailUrl": "{{ .url | absURL }}", {{- with dict "Path" . "Resources" $.Resources | partial "function/resource.html" -}}
"thumbnailUrl": "{{ .Permalink }}",
{{- else -}}
"thumbnailUrl": "{{ . | absURL }}",
{{- end -}}
{{- end -}} {{- end -}}
{{- with .Site.Copyright -}} {{- with .Site.Copyright -}}
"license": "{{ . | safeHTML }}", "license": "{{ . | safeHTML }}",
@ -60,13 +74,36 @@
"@type": "WebPage", "@type": "WebPage",
"@id": "{{ .Permalink }}" "@id": "{{ .Permalink }}"
}, },
{{- if ge $params.seo.image.width 696 -}} {{- $images := $params.seo.images | default slice -}}
"image": { {{- if not $images -}}
"@type": "ImageObject", {{- with .Resources.GetMatch "featured-image-preview" -}}
"url": "{{ $params.seo.image.url | absURL }}", {{- $images = slice "featured-image-preview" -}}
"width": {{ $params.seo.image.width }}, {{- end -}}
"height": {{ $params.seo.image.height }} {{- with .Resources.GetMatch "featured-image" -}}
}, {{- $images = slice "featured-image" -}}
{{- end -}}
{{- end -}}
{{- with .Site.Params.seo.image -}}
{{- $images = $images | default (slice .) -}}
{{- end -}}
{{- with $images -}}
"image": [
{{- range $index, $value := . -}}
{{- if gt $index 0 }},{{ end -}}
{{- with dict "Path" $value "Resources" $.Resources | partial "function/resource.html" -}}
{
"@type": "ImageObject",
"url": "{{ .Permalink }}",
"width": {{ .Width }},
"height": {{ .Height }}
}
{{- else -}}
{{- with $value -}}
"{{ . | absURL }}"
{{- end -}}
{{- end -}}
{{- end -}}
],
{{- end -}} {{- end -}}
"genre": "{{ .Type }}", "genre": "{{ .Type }}",
{{- with .Params.tags -}} {{- with .Params.tags -}}
@ -85,18 +122,25 @@
{{- with .Site.Copyright -}} {{- with .Site.Copyright -}}
"license": {{ . | safeHTML }}, "license": {{ . | safeHTML }},
{{- end -}} {{- end -}}
{{- with $params.seo.publisher -}} {{- $publisher := .Params.author | default .Site.Author.name | default (T "author") | dict "name" -}}
"publisher": { {{- $publisher = $params.seo.publisher | default dict | merge $publisher -}}
"@type": "Organization", "publisher": {
"name": {{ .name | safeHTML }}, "@type": "Organization",
"logo": { "name": {{ $publisher.name | safeHTML }}
"@type": "ImageObject", {{- $logo := $publisher.logoUrl -}}
"url": "{{ .logo.url | absURL }}", {{- with dict "Path" $logo "Resources" .Resources | partial "function/resource.html" -}}
"width": {{ .logo.width }}, ,"logo": {
"height": {{ .logo.height }} "@type": "ImageObject",
"url": "{{ .Permalink }}",
"width": {{ .Width }},
"height": {{ .Height }}
} }
}, {{- else -}}
{{- end -}} {{- with $logo -}}
,"logo": "{{ . | absURL }}"
{{- end -}}
{{- end -}}
},
{{- with .Params.author | default .Site.Author.name | default (T "author") -}} {{- with .Params.author | default .Site.Author.name | default (T "author") -}}
"author": { "author": {
"@type": "Person", "@type": "Person",