Skip to content

Commit 095e1f5

Browse files
cez81lunny
authored andcommitted
Support for custom html meta (#1423)
* Support for custom html meta * Changed html meta description default
1 parent 6a39250 commit 095e1f5

File tree

4 files changed

+32
-4
lines changed

4 files changed

+32
-4
lines changed

conf/app.ini

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,11 @@ ORG_PAGING_NUM = 50
7474
; Number of repos that are showed in one page
7575
REPO_PAGING_NUM = 15
7676

77+
[ui.meta]
78+
AUTHOR = Gitea - Git with a cup of tea
79+
DESCRIPTION = Gitea (Git with a cup of tea) is a painless self-hosted Git service written in Go
80+
KEYWORDS = go,git,self-hosted,gitea
81+
7782
[markdown]
7883
; Enable hard line break extension
7984
ENABLE_HARD_LINE_BREAK = false

modules/setting/setting.go

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -226,6 +226,11 @@ var (
226226
User struct {
227227
RepoPagingNum int
228228
} `ini:"ui.user"`
229+
Meta struct {
230+
Author string
231+
Description string
232+
Keywords string
233+
} `ini:"ui.meta"`
229234
}{
230235
ExplorePagingNum: 20,
231236
IssuePagingNum: 10,
@@ -248,6 +253,15 @@ var (
248253
}{
249254
RepoPagingNum: 15,
250255
},
256+
Meta: struct {
257+
Author string
258+
Description string
259+
Keywords string
260+
}{
261+
Author: "Gitea - Git with a cup of tea",
262+
Description: "Gitea (Git with a cup of tea) is a painless self-hosted Git service written in Go",
263+
Keywords: "go,git,self-hosted,gitea",
264+
},
251265
}
252266

253267
// Markdown settings

modules/templates/helper.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,15 @@ func NewFuncMap() []template.FuncMap {
110110
"ThemeColorMetaTag": func() string {
111111
return setting.UI.ThemeColorMetaTag
112112
},
113+
"MetaAuthor": func() string {
114+
return setting.UI.Meta.Author
115+
},
116+
"MetaDescription": func() string {
117+
return setting.UI.Meta.Description
118+
},
119+
"MetaKeywords": func() string {
120+
return setting.UI.Meta.Keywords
121+
},
113122
"FilenameIsImage": func(filename string) bool {
114123
mimeType := mime.TypeByExtension(filepath.Ext(filename))
115124
return strings.HasPrefix(mimeType, "image/")

templates/base/head.tmpl

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@
55
<meta http-equiv="x-ua-compatible" content="ie=edge">
66
<title>{{if .Title}}{{.Title}} - {{end}}{{AppName}}</title>
77
<meta name="theme-color" content="{{ThemeColorMetaTag}}">
8-
<meta name="author" content="{{if .Repository}}{{.Owner.Name}}{{else}}Gitea - Git with a cup of tea{{end}}" />
9-
<meta name="description" content="{{if .Repository}}{{.Repository.Name}}{{if .Repository.Description}} - {{.Repository.Description}}{{end}}{{else}}Gitea (Git with a cup of tea) is a painless self-hosted Git service written in Go{{end}}" />
10-
<meta name="keywords" content="go, git, self-hosted, gitea">
8+
<meta name="author" content="{{if .Repository}}{{.Owner.Name}}{{else}}{{MetaAuthor}}{{end}}" />
9+
<meta name="description" content="{{if .Repository}}{{.Repository.Name}}{{if .Repository.Description}} - {{.Repository.Description}}{{end}}{{else}}{{MetaDescription}}{{end}}" />
10+
<meta name="keywords" content="{{MetaKeywords}}">
1111
<meta name="referrer" content="no-referrer" />
1212
<meta name="_csrf" content="{{.CsrfToken}}" />
1313
<meta name="_suburl" content="{{AppSubUrl}}" />
@@ -68,7 +68,7 @@
6868
<meta property="og:type" content="website" />
6969
<meta property="og:image" content="{{AppSubUrl}}/img/gitea-lg.png" />
7070
<meta property="og:url" content="{{AppUrl}}" />
71-
<meta property="og:description" content="Gitea (Git with a cup of tea) is a painless self-hosted Git service written in Go">
71+
<meta property="og:description" content="{{MetaDescription}}">
7272
{{end}}
7373
</head>
7474
<body>

0 commit comments

Comments
 (0)