Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit ff093cc

Browse files
committed
SEO优化
1 parent 4105b21 commit ff093cc

40 files changed

+19
-72
lines changed

src/http/http.go

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -193,9 +193,16 @@ func executeTpl(ctx echo.Context, tpl *template.Template, data map[string]interf
193193
if jsTpl := tpl.Lookup("js"); jsTpl == nil {
194194
tpl.Parse(`{{define "js"}}{{end}}`)
195195
}
196-
if jsTpl := tpl.Lookup("css"); jsTpl == nil {
196+
if cssTpl := tpl.Lookup("css"); cssTpl == nil {
197197
tpl.Parse(`{{define "css"}}{{end}}`)
198198
}
199+
// 如果没有 seo 模板,则定义之
200+
if seoTpl := tpl.Lookup("seo"); seoTpl == nil {
201+
tpl.Parse(`{{define "seo"}}
202+
<meta name="keywords" content="` + logic.WebsiteSetting.SeoKeywords + `">
203+
<meta name="description" content="` + logic.WebsiteSetting.SeoKeywords + `">
204+
{{end}}`)
205+
}
199206

200207
// 当前用户信息
201208
curUser, ok := ctx.Get("user").(*model.Me)

template/403.html

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
11
{{define "title"}}对不起,没有操作权限 {{end}}
2-
{{define "seo"}}<meta name="keywords" content="Go语言,Golang,Go社区,Go中文社区,Golang中文社区,Go语言社区,Go语言学习,学习Go语言,Go语言学习园地,Golang 中国,Golang中国,Golang China, Go语言论坛">
3-
<meta name="description" content="Go语言中文网,中国 Golang 社区,Go语言学习园地,致力于构建完善的 Golang 中文社区,Go语言爱好者的学习家园。分享 Go 语言知识,交流使用经验">{{end}}
42
{{define "content"}}
53
<div class="row box_white">
64
<div class="col-md-12">

template/404.html

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
11
{{define "title"}}寻找遗失儿童 {{end}}
2-
{{define "seo"}}<meta name="keywords" content="Go语言,Golang,Go社区,Go中文社区,Golang中文社区,Go语言社区,Go语言学习,学习Go语言,Go语言学习园地,Golang 中国,Golang中国,Golang China, Go语言论坛">
3-
<meta name="description" content="Go语言中文网,中国 Golang 社区,Go语言学习园地,致力于构建完善的 Golang 中文社区,Go语言爱好者的学习家园。分享 Go 语言知识,交流使用经验">{{end}}
42
{{define "content"}}
53
<div class="row box_white">
64
<div class="col-md-6">

template/500.html

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
11
{{define "title"}}对不起,该页面出错了 {{end}}
2-
{{define "seo"}}<meta name="keywords" content="Go语言,Golang,Go社区,Go中文社区,Golang中文社区,Go语言社区,Go语言学习,学习Go语言,Go语言学习园地,Golang 中国,Golang中国,Golang China, Go语言论坛">
3-
<meta name="description" content="Go语言中文网,中国 Golang 社区,Go语言学习园地,致力于构建完善的 Golang 中文社区,Go语言爱好者的学习家园。分享 Go 语言知识,交流使用经验">{{end}}
42
{{define "content"}}
53
<div id="main" class="container-fluid">
64
<div class="content">

template/articles/detail.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{{define "title"}}{{.article.Title}} {{end}}
2-
{{define "seo"}}<meta name="keywords" content="{{.article.Title}}, Go语言博客文章, Go语言博文, Go语言, Golang, Go中文社区,Golang中文社区, Go语言社区, Go语言学习园地">
2+
{{define "seo"}}<meta name="keywords" content="{{.setting.SeoKeywords}}">
33
<meta name="description" content="{{substring .article.Txt 200 ""}}">{{end}}
44
{{define "content"}}
55
<div class="row banner">

template/articles/list.html

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
11
{{define "title"}}网友博文{{end}}
2-
{{define "seo"}}<meta name="keywords" content="Go语言博客文章, Go语言博文, Go语言, Golang, Go中文社区,Golang中文社区, Go语言社区, Go语言学习园地">
3-
<meta name="description" content="文章来自国内知名网站,Go爱好者学习笔记,经验分享;也有爱好者自己的博客文章,以及一些国外精彩文章。">{{end}}
42
{{define "content"}}
53
<div class="row banner">
64
</div>

template/articles/new.html

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
11
{{define "title"}}发布文章 {{end}}
2-
{{define "seo"}}<meta name="keywords" content="发布文章,Golang,Go社区,Golang中文社区,Go语言学习,Go语言,学习Go语言,Golang 中国,Golang中国,Golang China, Go语言论坛, Go中文社区, Go语言社区, Go语言中文网, Go语言学习园地">
3-
<meta name="description" content="Go语言中文网,Go中文社区,Golang中国,Go语言学习园地,提供一个Go爱好者交流的中文平台">{{end}}
42
{{define "content"}}
53
<div class="row">
64
<div class="col-lg-9 col-md-8 col-sm-7">

template/books/detail.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{{define "title"}}{{.book.Name}} {{end}}
2-
{{define "seo"}}<meta name="keywords" content="{{.book.Name}}, Go语言图书, Go语言, Golang, Go中文社区,Golang中文社区, Go语言社区, Go语言学习园地,Go语言中文网">
2+
{{define "seo"}}<meta name="keywords" content="{{.book.Name}},{{.setting.SeoKeywords}}">
33
<meta name="description" content="{{substring .book.Desc 200 ""}}">{{end}}
44
{{define "content"}}
55
<div class="row banner">

template/books/list.html

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
11
{{define "title"}}图书{{end}}
2-
{{define "seo"}}<meta name="keywords" content="Go语言图书, Go语言, Golang, Go中文社区,Golang中文社区, Go语言社区, Go语言学习园地,Go语言中文网">
3-
<meta name="description" content="汇总了国内外Go语言相关的图书">{{end}}
42
{{define "content"}}
53
<div class="row banner">
64
</div>

template/favorite.html

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
11
{{define "title"}}{{.user.Username}}的收藏{{end}}
2-
{{define "seo"}}<meta name="keywords" content="{{.user.Username}}的收藏, Go语言, Golang, Go中文社区, Golang中文社区, Go语言社区, Go语言中文网, Go语言学习园地">
3-
<meta name="description" content="我收藏的主题、资源、文章和项目等">{{end}}
42
{{define "content"}}
53
<div class="row banner">
64
</div>

0 commit comments

Comments
 (0)