1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
|
{%- macro theme() %}
{%- if config.extra.js_theme %}
{%- if config.extra.js_themeButton or config.extra.js_bundle %}
<script src="{{ get_url(path=config.extra.js_theme, trailing_slash=false) | safe }}"{%- if config.extra.integrity %} integrity="sha384-{{ get_file_hash(path=config.extra.js_theme, sha_type=384, base64=true) | safe }}"{%- endif %}></script>
{%- endif %}
{%- endif %}
{%- endmacro %}
{%- macro stylesheets() %}
{%- if config.extra.stylesheets %}{%- for i in config.extra.stylesheets %}
<link rel="stylesheet" href="{{ get_url(path=i, trailing_slash=false, cachebust=true) | safe }}" />
{%- endfor %}{%- endif %}
{%- endmacro %}
{%- macro stylesheets_preload() %}
{%- if config.extra.fonts %}{%- for i in config.extra.fonts %}
{%- if i.url is matching("^http[s]?://") %}
<link rel="preload" as="style" class="preStyle" href="{{ i.url | safe }}" crossorigin="anonymous" />
{%- else %}
<link rel="preload" as="font" href="{{ get_url(path=i.url, trailing_slash=false) | safe }}" type="font/woff2" />
{%- endif %}
{%- endfor %}{%- endif %}
{%- if config.extra.fontawesome %}
<link rel="preload" as="style" class="preStyle" href="{{ config.extra.fontawesome | safe }}" crossorigin="anonymous" />
{%- endif %}
{%- if config.extra.math or page.extra.math %}
{%- if config.extra.katex_css %}{%- if config.extra.katex_css is matching("^http[s]?://") %}
<link rel="preload" as="style" class="preStyle" href="{{ config.extra.katex_css | safe }}"{%- if config.extra.integrity %} integrity="sha384-ZPe7yZ91iWxYumsBEOn7ieg8q/o+qh/hQpSaPow8T6BwALcXSCS6C6fSRPIAnTQs"{%- endif %} crossorigin="anonymous" />
{%- else %}
<link rel="preload" as="style" class="preStyle" href="{{ get_url(path=config.extra.katex_css, trailing_slash=false) }}"{%- if config.extra.integrity %} integrity="sha384-{{ get_file_hash(path=config.extra.katex_css, sha_type=384, base64=true) | safe }}"{%- endif %} />
{%- endif %}{%- endif %}
{%- endif %}
{%- endmacro %}
{%- macro feed() %}
{%- if config.generate_feed %}
<link rel="alternate" type="{% if config.feed_filename is containing('atom') %}application/atom+xml{% else %}application/rss+xml{% endif %}" title="Atom/RSS Feed" href="{{ get_url(path=config.feed_filename, trailing_slash=false) | safe }}" />
{%- endif %}
{%- endmacro %}
{%- macro js() %}
{%- set preStyle = false %}
{%- if config.extra.fonts %}{%- for i in config.extra.fonts %}
{%- if i.url is matching("^http[s]?://") %}
{%- set preStyle = true %}
{%- endif %}
{%- endfor %}{%- endif %}
{%- if config.extra.fontawesome %}
{%- set preStyle = true %}
{%- endif %}
{%- if config.extra.math or page.extra.math %}
{%- if config.extra.katex_css %}
{%- set preStyle = true %}
{%- endif %}
{%- endif %}
{%- if config.build_search_index and config.extra.js_bundle %}
{%- if config.extra.js_search_index %}
<script defer src="{{ get_url(path=config.extra.js_search_index, trailing_slash=false, cachebust=true) | safe }}"{%- if config.extra.integrity %} integrity="sha384-{{ get_file_hash(path=config.extra.js_search_index, sha_type=384, base64=true) | safe }}"{%- endif %}></script>
{%- endif %}
{%- if config.extra.js_bundle %}
<script defer src="{{ get_url(path=config.extra.js_bundle, trailing_slash=false, cachebust=true) | safe }}"{%- if config.extra.integrity %} integrity="sha384-{{ get_file_hash(path=config.extra.js_bundle, sha_type=384, base64=true) | safe }}"{%- endif %}></script>
{%- endif %}
{%- elif config.build_search_index %}
{#- no bundle #}
{%- if preStyle == true %}
{%- if config.extra.js_prestyle %}
<script defer src="{{ get_url(path=config.extra.js_prestyle, trailing_slash=false, cachebust=true) | safe }}"{%- if config.extra.integrity %} integrity="sha384-{{ get_file_hash(path=config.extra.js_prestyle, sha_type=384, base64=true) | safe }}"{%- endif %}></script>
{%- endif %}
{%- endif %}
{%- if config.extra.js_theme %}
{%- if config.extra.js_themeButton %}
<script defer src="{{ get_url(path=config.extra.js_themeButton, trailing_slash=false) | safe }}"{%- if config.extra.integrity %} integrity="sha384-{{ get_file_hash(path=config.extra.js_themeButton, sha_type=384, base64=true) | safe }}"{%- endif %}></script>
{%- endif %}
{%- endif %}
{%- if config.extra.js_email %}
{%- if config.extra.social.mail_encode %}
<script defer src="{{ get_url(path=config.extra.js_email, trzailing_slash=false, cachebust=true) | safe }}"{%- if config.extra.integrity %} integrity="sha384-{{ get_file_hash(path=config.extra.js_email, sha_type=384, base64=true) | safe }}"{%- endif %}></script>
{%- endif %}
{%- endif %}
{%- if config.extra.js_codecopy %}
<script defer src="{{ get_url(path=config.extra.js_codecopy, trailing_slash=false, cachebust=true) | safe }}"{%- if config.extra.integrity %} integrity="sha384-{{ get_file_hash(path=config.extra.js_codecopy, sha_type=384, base64=true) | safe }}"{%- endif %}></script>
{%- endif %}
{%- if config.extra.js_search_index %}
<script defer src="{{ get_url(path=config.extra.js_search_index, trailing_slash=false, cachebust=true) | safe }}"{%- if config.extra.integrity %} integrity="sha384-{{ get_file_hash(path=config.extra.js_search_index, sha_type=384, base64=true) | safe }}"{%- endif %}></script>
{%- endif %}
{%- if config.extra.js_search %}{%- for i in config.extra.js_search %}
<script defer src="{{ get_url(path=i, trailing_slash=false, cachebust=true) | safe }}"{%- if config.extra.integrity %} integrity="sha384-{{ get_file_hash(path=i, sha_type=384, base64=true) | safe }}"{%- endif %}></script>
{%- endfor %}{%- endif %}
{%- elif config.extra.js_bundle %}
{#- no search #}
<script defer src="{{ get_url(path=config.extra.js_bundle, trailing_slash=false, cachebust=true) | safe }}"{%- if config.extra.integrity %} integrity="sha384-{{ get_file_hash(path=config.extra.js_bundle, sha_type=384, base64=true) | safe }}"{%- endif %}></script>
{%- else %}
{#- no bundle or search #}
{%- if preStyle == true %}
{%- if config.extra.js_prestyle %}
<script defer src="{{ get_url(path=config.extra.js_prestyle, trailing_slash=false, cachebust=true) | safe }}"{%- if config.extra.integrity %} integrity="sha384-{{ get_file_hash(path=config.extra.js_prestyle, sha_type=384, base64=true) | safe }}"{%- endif %}></script>
{%- endif %}
{%- endif %}
{%- if config.extra.js_theme %}
{%- if config.extra.js_themeButton or config.extra.js_bundle %}
<script defer src="{{ get_url(path=config.extra.js_themeButton, trailing_slash=false) | safe }}"{%- if config.extra.integrity %} integrity="sha384-{{ get_file_hash(path=config.extra.js_themeButton, sha_type=384, base64=true) | safe }}"{%- endif %}></script>
{%- endif %}
{%- endif %}
{%- if config.extra.js_email %}
{%- if config.extra.social.mail_encode %}
<script defer src="{{ get_url(path=config.extra.js_email, trailing_slash=false, cachebust=true) | safe }}"{%- if config.extra.integrity %} integrity="sha384-{{ get_file_hash(path=config.extra.js_email, sha_type=384, base64=true) | safe }}"{%- endif %}></script>
{%- endif %}
{%- endif %}
{%- if config.extra.js_codecopy %}
<script defer src="{{ get_url(path=config.extra.js_codecopy, trailing_slash=false, cachebust=true) | safe }}"{%- if config.extra.integrity %} integrity="sha384-{{ get_file_hash(path=config.extra.js_codecopy, sha_type=384, base64=true) | safe }}"{%- endif %}></script>
{%- endif %}
{%- endif %}
{#- https://katex.org/docs/autorender.html #}
{#- https://github.com/KaTeX/KaTeX/ #}
{#- https://github.com/KaTeX/KaTeX/tree/main/contrib/mathtex-script-type/ #}
{%- if config.extra.math or page.extra.math %}
{%- if config.extra.katex_bundle %}
<script defer src="{{ get_url(path=config.extra.katex_bundle, trailing_slash=false, cachebust=true) }}"{%- if config.extra.integrity %} integrity="sha384-{{ get_file_hash(path=config.extra.katex_bundle, sha_type=384, base64=true) | safe }}"{%- endif %}></script>
{%- else %}
{%- if config.extra.katex_js %}{%- if config.extra.katex_js is matching("^http[s]?://") %}
<script defer src="{{ config.extra.katex_js | safe }}"{%- if config.extra.integrity %} integrity="sha384-ljao5I1l+8KYFXG7LNEA7DyaFvuvSCmedUf6Y6JI7LJqiu8q5dEivP2nDdFH31V4"{%- endif %} crossorigin="anonymous"></script>
{%- else %}
<script defer src="{{ get_url(path=config.extra.katex_js, trailing_slash=false, cachebust=true) }}"{%- if config.extra.integrity %} integrity="sha384-{{ get_file_hash(path=config.extra.katex_js, sha_type=384, base64=true) | safe }}"{%- endif %}></script>
{%- endif %}{%- endif %}
{%- if config.extra.mathtex_js %}{%- if config.extra.mathtex_js is matching("^http[s]?://") %}
<script defer src="{{ config.extra.mathtex_js | safe }}"{%- if config.extra.integrity %} integrity="sha384-jiBVvJ8NGGj5n7kJaiWwWp9AjC+Yh8rhZY3GtAX8yU28azcLgoRo4oukO87g7zDT"{%- endif %} crossorigin="anonymous"></script>
{%- else %}
<script defer src="{{ get_url(path=config.extra.mathtex_js, trailing_slash=false, cachebust=true) }}"{%- if config.extra.integrity %} integrity="sha384-{{ get_file_hash(path=config.extra.mathtex_js, sha_type=384, base64=true) | safe }}"{%- endif %}></script>
{%- endif %}{%- endif %}
{%- if config.extra.math_auto_render or page.extra.math_auto_render %}
{%- if config.extra.katex_autorender_js %}
{%- if config.extra.katex_autorender_js is matching("^http[s]?://") %}
<script defer src="{{ config.extra.katex_autorender_js | safe }}"{%- if config.extra.integrity %} integrity="sha384-+XBljXPPiv+OzfbB3cVmLHf4hdUFHlWNZN5spNQ7rmHTXpd7WvJum6fIACpNNfIR"{%- endif %} crossorigin="anonymous"></script>
{%- else %}
<script defer src="{{ get_url(path=config.extra.katex_autorender_js, trailing_slash=false, cachebust=true) }}"{%- if config.extra.integrity %} integrity="sha384-{{ get_file_hash(path=config.extra.katex_autorender_js, sha_type=384, base64=true) | safe }}"{%- endif %}></script>
{%- endif %}
{%- endif %}
<script defer src="{{ get_url(path=config.extra.katex_options, trailing_slash=false, cachebust=true) }}"{%- if config.extra.integrity %} integrity="sha384-{{ get_file_hash(path=config.extra.katex_options, sha_type=384, base64=true) | safe }}"{%- endif %}></script>
{%- endif %}
{%- endif %}
{%- endif %}
{%- endmacro %}
{%- macro favicons() %}
{%- if config.extra.favicon_theme_color %}
<meta name="theme-color" content="{{ config.extra.favicon_theme_color }}" />
{%- endif %}
{%- if config.extra.favicon_ms_color %}
<meta name="msapplication-TileColor" content="{{ config.extra.favicon_ms_color }}" />
{%- endif %}
{%- if config.extra.favicon_webmanifest %}
<link rel="manifest" href="{{ get_url(path=config.extra.favicon_webmanifest, trailing_slash=false) | safe }}" />
{%- endif %}
{%- if config.extra.favicon_mask and config.extra.favicon_mask_color %}
<link rel="mask-icon" href="{{ get_url(path=config.extra.favicon_mask, trailing_slash=false) | safe }}" color="{{ config.extra.favicon_mask_color }}" />
{%- endif %}
{%- if config.extra.favicon180 %}
<link rel="apple-touch-icon" sizes="180x180" href="{{ get_url(path=config.extra.favicon180, trailing_slash=false) | safe }}" />
{%- endif %}
{%- if config.extra.favicon32 %}
<link rel="icon" type="image/png" sizes="32x32" href="{{ get_url(path=config.extra.favicon32, trailing_slash=false) | safe }}" />
{%- endif %}
{%- if config.extra.favicon16 %}
<link rel="icon" type="image/png" sizes="16x16" href="{{ get_url(path=config.extra.favicon16, trailing_slash=false) | safe }}" />
{%- endif %}
{%- endmacro %}
{%- macro security() %}
{%- if config.extra.security_header_referrer %}
<meta name="referrer" content="{{ config.extra.security_header_referrer | safe }}" />
{%- endif %}
{%- if config.extra.security_header_csp %}
<meta http-equiv="Content-Security-Policy" content="{{ config.extra.security_header_csp | safe }}" />
{%- endif %}
{%- endmacro %}
{#- type: website or article, generally setting article for blog articles -#}
{#- page_images: using for the blog single template page -#}
{#- page_section: the blog single template page have to pass the parameter -#}
{#- is_404: using for the 404.html template -#}
{%- macro seo( title="",title_addition="",description="",type="website",is_home=false,is_404=false,is_page=false,page_images="",page_section="",created_time="2021-07-04T07:07:00-07:00", updated_time="2021-07-04T07:07:00-07:00" ) %}
{%- if is_404 -%}
<meta name="robots" content="noindex, follow" />
{%- else -%}
<meta name="robots" content="index, follow" />
<meta name="googlebot" content="index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1" />
<meta name="bingbot" content="index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1" />
{%- endif -%}
{%- if current_url %}
{%- set page_url = current_url %}
{%- else %}
{%- set page_url = get_url(path="404.html", trailing_slash=true) %}
{%- endif %}
<title>{{ title ~ title_addition }}</title>
{%- if config.extra.author %}
<meta name="author" content="{{ config.extra.author }}" />
{%- endif %}
{%- if config.extra.facebook_publisher %}
<meta property="article:publisher" content="https://www.facebook.com/{{ config.extra.facebook_publisher }}" />
{%- endif %}
<meta name="copyright" content="{{ config.title }}" />
{%- if config.extra.facebook_author %}
<meta property="article:author" content="https://www.facebook.com/{{ config.extra.facebook_author }}" />
{%- endif %}
{%- if page.description %}
<meta name="description" content="{{ page.description }}" />
{%- else %}
<meta name="description" content="{{ config.description }}" />
{%- endif %}
<link rel="canonical" href="{{ page_url | safe }}" />
{%- if page.extra.keywords %}
<meta name="keywords" content="{{ page.extra.keywords }}, {{ config.extra.keywords }}" />
{%- else %}
<meta name="keywords" content="{{ config.extra.keywords }}" />
{%- endif %}
{#- Extra SEO START #}
{%- if config.extra.seo | default(value=true) %}
{%- if not is_404 %}
{%- if config.extra.google %}
<meta name="google-site-verification" content="{{ config.extra.google | safe }}" />
{%- endif %}
{%- if config.extra.bing %}
<meta name="msvalidate.01" content="{{ config.extra.bing | safe}}" />
{%- endif %}
<meta property="og:url" content="{{ page_url | safe }}" />
<meta name="twitter:url" content="{{ page_url | safe }}" />
{%- if page.description %}
<meta property="og:description" content="{{ page.description }}" />
<meta name="twitter:description" content="{{ page.description }}" />
{%- else %}
<meta property="og:description" content="{{ config.description }}" />
<meta name="twitter:description" content="{{ config.description}}" />
{%- endif %}
{%- if page.title %}
<meta property="og:title" content="{{ page.title }} | {{ config.title }}" />
<meta name="twitter:title" content="{{ page.title }} | {{ config.title }}" />
{%- else %}
<meta property="og:title" content="{{ config.title }}" />
<meta name="twitter:title" content="{{ config.title }}" />
{%- endif %}
{#- SEO MEDIA START #}
{%- if page.extra.thumbnail %}
<meta name="twitter:card" content="summary_large_image" />
<meta name="twitter:image" content="{{ get_url(path=page.path ~ page.extra.thumbnail, trailing_slash=false) }}" />
<meta property="og:image" content="{{ get_url(path=page.path ~ page.extra.thumbnail, trailing_slash=false) }}" />
{%- elif page.extra.static_thumbnail %}
<meta name="twitter:card" content="summary_large_image" />
{%- if page.extra.static_thumbnail is matching("^http[s]?://") %}
<meta name="twitter:image" content="{{ page.extra.static_thumbnail }}" />
<meta property="og:image" content="{{ page.extra.static_thumbnail }}" />
{%- else %}
<meta name="twitter:image" content="{{ get_url(path=page.extra.static_thumbnail, trailing_slash=false) }}" />
<meta property="og:image" content="{{ get_url(path=page.extra.static_thumbnail, trailing_slash=false) }}" />
{%- endif %}
{%- elif config.extra.banner %}
<meta name="twitter:card" content="summary_large_image" />
<meta name="twitter:image" content="{{ get_url(path=config.extra.banner, trailing_slash=false) }}" />
<meta property="og:image" content="{{ get_url(path=config.extra.banner, trailing_slash=false) }}" />
{%- else %}
<meta name="twitter:card" content="summary" />
{%- endif %}
{%- if config.extra.open.audio %}
<meta property="og:audio" content="{{ config.extra.open.audio }}" />
{%- endif %}
{%- if config.extra.open.locale %}
<meta property="og:locale" content="{{ config.extra.open.locale }}" />
{%- endif %}
{%- if config.extra.open.videos %}
{%- for video in config.extra.open.videos %}
<meta property="og:video" content="{{ get_url(path=video) }}" />
{%- endfor %}
{%- endif %}
{#- SEO MEDIA END #}
<meta property="og:site_name" content="{{ config.title }}" />
<meta property="og:locale" content="en_US" />
<meta property="og:type" content="website" />
{%- if page.updated %}
<meta property="og:updated_time" content="{{ page.updated | date(format='%F') }}" />
{%- elif page.date %}
<meta property="og:updated_time" content="{{ page.date | date(format='%F') }}" />
{%- else %}
<meta property="og:updated_time" content="{{ updated_time }}" />
{%- endif %}
{%- if config.extra.social.twitter %}
<meta name="twitter:site" content="@{{ config.extra.twitter }}" />
<meta name="twitter:creator" content="@{{ config.extra.twitter }}" />
{%- endif %}
{%- endif %}
{%- endif %}
{#- Extra SEO END #}
{%- endmacro %}
|