Skip to content

Commit 469f273

Browse files
committed
add global robotsNoIndex option
1 parent adfcf0d commit 469f273

File tree

1 file changed

+167
-0
lines changed

1 file changed

+167
-0
lines changed

layouts/partials/head.html

Lines changed: 167 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,167 @@
1+
<meta charset="utf-8">
2+
<meta http-equiv="X-UA-Compatible" content="IE=edge">
3+
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
4+
{{- if hugo.IsProduction | or (eq site.Params.env "production") | and (ne (.Params.robotsNoIndex | default site.Params.robotsNoIndex) true) }}
5+
<meta name="robots" content="index, follow">
6+
{{- else }}
7+
<meta name="robots" content="noindex, nofollow">
8+
{{- end }}
9+
10+
{{- /* Title */}}
11+
<title>{{ if .IsHome }}{{ else }}{{ if .Title }}{{ .Title }} | {{ end }}{{ end }}{{ site.Title }}</title>
12+
13+
{{- /* Meta */}}
14+
{{- if .IsHome }}
15+
{{ with site.Params.keywords -}}<meta name="keywords" content="{{- range $i, $e := . }}{{ if $i }}, {{ end }}{{ $e }}{{ end }}">{{ end }}
16+
{{- else }}
17+
<meta name="keywords" content="{{ if .Params.keywords -}}
18+
{{- range $i, $e := .Params.keywords }}{{ if $i }}, {{ end }}{{ $e }}{{ end }} {{- else }}
19+
{{- range $i, $e := .Params.tags }}{{ if $i }}, {{ end }}{{ $e }}{{ end }} {{- end -}}">
20+
{{- end }}
21+
<meta name="description" content="{{- with .Description }}{{ . }}{{- else }}{{- if or .IsPage .IsSection}}
22+
{{- .Summary | default (printf "%s - %s" .Title site.Title) }}{{- else }}
23+
{{- with site.Params.description }}{{ . }}{{- end }}{{- end }}{{- end -}}">
24+
<meta name="author" content="{{ (partial "author.html" . ) }}">
25+
<link rel="canonical" href="{{ if .Params.canonicalURL -}} {{ trim .Params.canonicalURL " " }} {{- else -}} {{ .Permalink }} {{- end }}">
26+
{{- if site.Params.analytics.google.SiteVerificationTag }}
27+
<meta name="google-site-verification" content="{{ site.Params.analytics.google.SiteVerificationTag }}">
28+
{{- end }}
29+
{{- if site.Params.analytics.yandex.SiteVerificationTag }}
30+
<meta name="yandex-verification" content="{{ site.Params.analytics.yandex.SiteVerificationTag }}">
31+
{{- end }}
32+
{{- if site.Params.analytics.bing.SiteVerificationTag }}
33+
<meta name="msvalidate.01" content="{{ site.Params.analytics.bing.SiteVerificationTag }}">
34+
{{- end }}
35+
36+
{{- /* Styles */}}
37+
38+
{{- /* includes */}}
39+
{{- $includes := slice }}
40+
{{- $includes = $includes | append (" " | resources.FromString "assets/css/includes-blank.css")}}
41+
42+
{{- if not (eq site.Params.assets.disableScrollBarStyle true) }}
43+
{{- $ScrollStyle := (resources.Get "css/includes/scroll-bar.css") }}
44+
{{- $includes = (append $ScrollStyle $includes) }}
45+
{{- end }}
46+
47+
{{- $includes_all := $includes | resources.Concat "assets/css/includes.css" }}
48+
49+
{{- $theme_vars := (resources.Get "css/core/theme-vars.css") }}
50+
{{- $reset := (resources.Get "css/core/reset.css") }}
51+
{{- $media := (resources.Get "css/core/zmedia.css") }}
52+
{{- $license_css := (resources.Get "css/core/license.css") }}
53+
{{- $common := (resources.Match "css/common/*.css") | resources.Concat "assets/css/common.css" }}
54+
55+
{{- /* include `an-old-hope` if hljs is on */}}
56+
{{- $isHLJSdisabled := (site.Params.assets.disableHLJS | default false) }}
57+
{{- $hljs := (cond ($isHLJSdisabled) (".chroma { background-color: unset !important;}" | resources.FromString "assets/css/hljs-blank.css") (resources.Get "css/hljs/an-old-hope.min.css")) }}
58+
59+
{{- /* order is important */}}
60+
{{- $core := (slice $theme_vars $reset $common $hljs $includes_all $media) | resources.Concat "assets/css/core.css" | resources.Minify }}
61+
{{- $extended := (resources.Match "css/extended/*.css") | resources.Concat "assets/css/extended.css" | resources.Minify }}
62+
63+
{{- /* bundle all required css */}}
64+
{{- /* Add extended css after theme style */ -}}
65+
{{- $stylesheet := (slice $license_css $core $extended) | resources.Concat "assets/css/stylesheet.css" }}
66+
67+
{{- if not site.Params.assets.disableFingerprinting }}
68+
{{- $stylesheet := $stylesheet | fingerprint }}
69+
<link crossorigin="anonymous" href="{{ $stylesheet.RelPermalink }}" integrity="{{ $stylesheet.Data.Integrity }}" rel="preload stylesheet" as="style">
70+
{{- else }}
71+
<link crossorigin="anonymous" href="{{ $stylesheet.RelPermalink }}" rel="preload stylesheet" as="style">
72+
{{- end }}
73+
74+
{{- /* Search */}}
75+
{{- if (eq .Layout `search`) -}}
76+
<link crossorigin="anonymous" rel="preload" as="fetch" href="../index.json">
77+
{{- $fastsearch := resources.Get "js/fastsearch.js" | js.Build (dict "params" (dict "fuseOpts" site.Params.fuseOpts)) | resources.Minify }}
78+
{{- $fusejs := resources.Get "js/fuse.basic.min.js" }}
79+
{{- $license_js := resources.Get "js/license.js" }}
80+
{{- if not site.Params.assets.disableFingerprinting }}
81+
{{- $search := (slice $fusejs $license_js $fastsearch ) | resources.Concat "assets/js/search.js" | fingerprint }}
82+
<script defer crossorigin="anonymous" src="{{ $search.RelPermalink }}" integrity="{{ $search.Data.Integrity }}"></script>
83+
{{- else }}
84+
{{- $search := (slice $fusejs $fastsearch ) | resources.Concat "assets/js/search.js" }}
85+
<script defer crossorigin="anonymous" src="{{ $search.RelPermalink }}"></script>
86+
{{- end }}
87+
{{- end -}}
88+
89+
{{- /* Highlight.js */}}
90+
{{- $isHLJSdisabled := (site.Params.assets.disableHLJS | default .Params.disableHLJS ) }}
91+
{{- if (and (eq .Kind "page") (ne .Layout "archives") (ne .Layout "search") (not $isHLJSdisabled)) }}
92+
{{- if not site.Params.assets.disableFingerprinting }}
93+
{{- $highlight := slice (resources.Get "js/highlight.min.js") | resources.Concat "assets/js/highlight.js" | fingerprint }}
94+
<script defer crossorigin="anonymous" src="{{ $highlight.RelPermalink }}" integrity="{{ $highlight.Data.Integrity }}"
95+
onload="hljs.initHighlightingOnLoad();"></script>
96+
{{- else }}
97+
{{- $highlight := slice (resources.Get "js/highlight.min.js") | resources.Concat "assets/js/highlight.js" }}
98+
<script defer crossorigin="anonymous" src="{{ $highlight.RelPermalink }}" onload="hljs.initHighlightingOnLoad();"></script>
99+
{{- end }}
100+
{{- end }}
101+
102+
{{- /* Favicons */}}
103+
<link rel="icon" href="{{ site.Params.assets.favicon | default "favicon.ico" | absURL }}">
104+
<link rel="icon" type="image/png" sizes="16x16" href="{{ site.Params.assets.favicon16x16 | default "favicon-16x16.png" | absURL }}">
105+
<link rel="icon" type="image/png" sizes="32x32" href="{{ site.Params.assets.favicon32x32 | default "favicon-32x32.png" | absURL }}">
106+
<link rel="apple-touch-icon" href="{{ site.Params.assets.apple_touch_icon | default "apple-touch-icon.png" | absURL }}">
107+
<link rel="mask-icon" href="{{ site.Params.assets.safari_pinned_tab | default "safari-pinned-tab.svg" | absURL }}">
108+
<meta name="theme-color" content="{{ site.Params.assets.theme_color | default "#2e2e33" }}">
109+
<meta name="msapplication-TileColor" content="{{ site.Params.assets.msapplication_TileColor | default "#2e2e33" }}">
110+
111+
{{- /* RSS */}}
112+
{{ range .AlternativeOutputFormats -}}
113+
<link rel="{{ .Rel }}" type="{{ .MediaType.Type | html }}" href="{{ .Permalink | safeURL }}">
114+
{{ end -}}
115+
{{- range .AllTranslations -}}
116+
<link rel="alternate" hreflang="{{ .Lang }}" href="{{ .Permalink }}">
117+
{{ end -}}
118+
119+
<noscript>
120+
<style>
121+
#theme-toggle,
122+
.top-link {
123+
display: none;
124+
}
125+
126+
</style>
127+
{{- if (and (ne site.Params.defaultTheme "light") (ne site.Params.defaultTheme "dark")) }}
128+
<style>
129+
@media (prefers-color-scheme: dark) {
130+
:root {
131+
--theme: rgb(29, 30, 32);
132+
--entry: rgb(46, 46, 51);
133+
--primary: rgb(218, 218, 219);
134+
--secondary: rgb(155, 156, 157);
135+
--tertiary: rgb(65, 66, 68);
136+
--content: rgb(196, 196, 197);
137+
--hljs-bg: rgb(46, 46, 51);
138+
--code-bg: rgb(55, 56, 62);
139+
--border: rgb(51, 51, 51);
140+
}
141+
142+
.list {
143+
background: var(--theme);
144+
}
145+
146+
.list:not(.dark)::-webkit-scrollbar-track {
147+
background: 0 0;
148+
}
149+
150+
.list:not(.dark)::-webkit-scrollbar-thumb {
151+
border-color: var(--theme);
152+
}
153+
}
154+
155+
</style>
156+
{{- end }}
157+
</noscript>
158+
159+
{{- partial "extend_head.html" . -}}
160+
161+
{{- /* Misc */}}
162+
{{- if hugo.IsProduction | or (eq site.Params.env "production") }}
163+
{{- template "_internal/google_analytics.html" . }}
164+
{{- template "partials/templates/opengraph.html" . }}
165+
{{- template "partials/templates/twitter_cards.html" . }}
166+
{{- template "partials/templates/schema_json.html" . }}
167+
{{- end -}}

0 commit comments

Comments
 (0)