Skip to content

Commit e387cf7

Browse files
committed
docs: optimize head section of templates
Reordered the head section of website/www using capo.js to improve speed. Tried to do the same for the doc/_template/layout.html. Due to a bug in sphinx, we get duplicate viewport tags. sphinx-doc/sphinx#11699 but I think it's harmless.
1 parent b8a88c4 commit e387cf7

File tree

2 files changed

+34
-28
lines changed

2 files changed

+34
-28
lines changed

doc/_templates/layout.html

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -105,24 +105,10 @@ <h3>{{ _('Quick search') }}</h3>
105105
<head>
106106
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
107107
<meta name="viewport" content="width=device-width, initial-scale=1">
108-
{%- if 'name="description"' not in metatags %}
109-
<meta name="description"
110-
content="Page {{ pagename }} in documentation on the Roundup issue tracker, version {{ release|e }}.">
111-
{%- endif %}
112-
{{ metatags }}
113108
{%- if builder != 'htmlhelp' %}
114109
{%- set titlesuffix = " &mdash; "|safe + docstitle|e %}
115110
{%- endif %}
116111
<title>{{ title|striptags }}{{ titlesuffix }}</title>
117-
{%- if builder == 'web' %}
118-
<link rel="stylesheet" href="{{ pathto('index') }}?do=stylesheet{%
119-
if in_admin_panel %}&admin=yes{% endif %}" type="text/css" />
120-
{%- for link, type, title in page_links %}
121-
<link rel="alternate" type="{{ type|e(true) }}" title="{{ title|e(true) }}" href="{{ link|e(true) }}" />
122-
{%- endfor %}
123-
{%- else %}
124-
{{ css() }}
125-
{%- endif %}
126112
{%- if builder != 'htmlhelp' %}
127113
<script type="text/javascript">
128114
var DOCUMENTATION_OPTIONS = {
@@ -135,6 +121,22 @@ <h3>{{ _('Quick search') }}</h3>
135121
{%- for scriptfile in script_files %}
136122
<script type="text/javascript" src="{{ pathto(scriptfile, 1) }}"></script>
137123
{%- endfor %}
124+
{%- if builder == 'web' %}
125+
<link rel="stylesheet" href="{{ pathto('index') }}?do=stylesheet{%
126+
if in_admin_panel %}&admin=yes{% endif %}" type="text/css" />
127+
{%- for link, type, title in page_links %}
128+
<link rel="alternate" type="{{ type|e(true) }}" title="{{ title|e(true) }}" href="{{ link|e(true) }}" />
129+
{%- endfor %}
130+
{%- else %}
131+
{{ css() }}
132+
{%- endif %}
133+
<!-- https://github.com/sphinx-doc/sphinx/issues/11699 means a
134+
duplicate viewport tag -->
135+
{{ metatags }}
136+
{%- if 'name="description"' not in metatags %}
137+
<meta name="description"
138+
content="Page {{ pagename }} in documentation on the Roundup issue tracker, version {{ release|e }}.">
139+
{%- endif %}
138140
{%- if use_opensearch %}
139141
<link rel="search" type="application/opensearchdescription+xml"
140142
title="{% trans docstitle=docstitle|e %}Search within {{ docstitle }}{% endtrans %}"

website/www/_templates/layout.html

Lines changed: 18 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -7,25 +7,12 @@
77
<head>
88
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
99
<meta name="viewport" content="width=device-width, initial-scale=1">
10-
{%- if 'name="description"' not in metatags %}
11-
<meta name="description"
12-
content="Page {{ pagename }} in documentation on the Roundup issue tracker, version {{ release|e }}.">
13-
{%- endif %}
14-
{{ metatags }}
1510
{%- if builder != 'htmlhelp' %}
1611
{%- set titlesuffix = docstitle|e %}
1712
{%- set titlesuffix = " - " + titlesuffix %}
1813
{%- endif %}
1914
<title>{{ title|striptags }}{{ titlesuffix }}</title>
20-
{%- if builder == 'web' %}
21-
<link rel="stylesheet" href="{{ pathto('index') }}?do=stylesheet{%
22-
if in_admin_panel %}&admin=yes{% endif %}" type="text/css" />
23-
{%- for link, type, title in page_links %}
24-
<link rel="alternate" type="{{ type|e(true) }}" title="{{ title|e(true) }}" href="{{ link|e(true) }}" />
25-
{%- endfor %}
26-
{%- else %}
27-
<link rel="stylesheet" href="{{ pathto('_static/style.css', 1) }}" type="text/css" />
28-
{%- endif %}
15+
2916
{%- if builder != 'htmlhelp' %}
3017
<script type="text/javascript">
3118
var DOCUMENTATION_OPTIONS = {
@@ -41,6 +28,23 @@
4128
{%- endfor %}
4229
<script type="text/javascript">$('#searchbox').show(0);</script>
4330
{%- endif %}
31+
32+
{%- if builder == 'web' %}
33+
<link rel="stylesheet" href="{{ pathto('index') }}?do=stylesheet{%
34+
if in_admin_panel %}&admin=yes{% endif %}" type="text/css" />
35+
{%- for link, type, title in page_links %}
36+
<link rel="alternate" type="{{ type|e(true) }}" title="{{ title|e(true) }}" href="{{ link|e(true) }}" />
37+
{%- endfor %}
38+
{%- else %}
39+
<link rel="stylesheet" href="{{ pathto('_static/style.css', 1) }}" type="text/css" />
40+
{%- endif %}
41+
<!-- https://github.com/sphinx-doc/sphinx/issues/11699 means a
42+
duplicate viewport tag -->
43+
{{ metatags }}
44+
{%- if 'name="description"' not in metatags %}
45+
<meta name="description"
46+
content="Page {{ pagename }} in documentation on the Roundup issue tracker, version {{ release|e }}.">
47+
{%- endif %}
4448
{%- if pageurl %}
4549
<link rel="canonical" href="{{ pageurl|e }}" />
4650
{%- endif %}

0 commit comments

Comments
 (0)