1
- Technical Documentation Search Engine Optimization (SEO) Guide
2
- ==============================================================
1
+ Search Engine Optimization (SEO) for documentation projects
2
+ ===========================================================
3
3
4
4
.. meta ::
5
5
:description lang=en:
6
- Looking to optimize your Sphinx documentation for search engines?
6
+ Looking to optimize your documentation project for search engines?
7
7
This SEO guide will help your docs be better understood by both people and crawlers
8
8
as well as help you rank higher in search engine results.
9
9
10
+ This article explains how documentation can be optimized to appear in search results,
11
+ ultimately increasing traffic to your docs.
10
12
11
- This guide will help you optimize your documentation for search engines
12
- with the goal of increasing traffic to your docs.
13
- While you optimize your docs to make them more crawler friendly for search engine spiders,
13
+ While you optimize your docs to make them more friendly for search engine spiders/crawlers,
14
14
it's important to keep in mind that your ultimate goal is to make your docs
15
- more discoverable for your users.
16
- **You're trying to make sure that when a user types a question into a search engine
17
- that is answerable by your documentation, that your docs appear in the results. **
15
+ more :term: `discoverable <discoverability> ` for your users.
18
16
19
- This guide isn't meant to be your only resource on SEO,
20
- and there's a lot of SEO topics not covered here.
21
- For additional reading, please see the
22
- :ref: `external resources <guides/technical-docs-seo-guide:External resources >` section.
17
+ By following :ref: `our best practices for SEO <guides/technical-docs-seo-guide:Best practices for documentation SEO >`,
18
+ you can ensure that when a user types a question into a search engine,
19
+ they can get the answers from your documentation in the search results.
23
20
24
- While many of the topics here apply to all forms of technical documentation,
25
- this guide will focus on Sphinx, which is the most common
26
- documentation authoring tool on Read the Docs,
27
- as well as improvements provided by Read the Docs itself.
21
+ .. seealso ::
28
22
29
-
30
- .. contents :: Table of contents
31
- :local:
32
- :backlinks: none
33
- :depth: 3
23
+ This guide isn't meant to be your only resource on SEO,
24
+ and there's a lot of SEO topics not covered here.
25
+ For additional reading, please see the
26
+ :ref: `external resources <guides/technical-docs-seo-guide:External resources >` section.
34
27
35
28
36
29
SEO Basics
@@ -80,8 +73,8 @@ generates static HTML and the performance is typically decent
80
73
relative to most of the internet.
81
74
82
75
83
- Optimizing your docs for search engine spiders
84
- ----------------------------------------------
76
+ Best practices for documentation SEO
77
+ ------------------------------------
85
78
86
79
Once a crawler or spider finds your site, it will follow links and redirects
87
80
in an attempt to find any and all pages on your site.
@@ -92,30 +85,53 @@ which we'll discuss shortly,
92
85
the most important thing is making sure the spider can follow links on your site
93
86
and get to all your pages.
94
87
95
- Avoid orphan pages
96
- ~~~~~~~~~~~~~~~~~~
88
+ Avoid unlinked pages ✅️
89
+ ~~~~~~~~~~~~~~~~~~~~~~~~
97
90
98
- Sphinx calls pages that don't have links to them "orphans"
99
- and will throw a warning while building documentation that contains an orphan
100
- unless the warning is silenced with the :ref: ` orphan directive < sphinx:metadata >`:
91
+ When building your documentation,
92
+ you should ensure that pages aren't * unlinked *,
93
+ meaning that no other pages or navigation have a link to them.
101
94
102
- ::
95
+ Search engine crawlers will not discover pages that aren't linked from somewhere else on your site.
103
96
104
- $ make html
105
- sphinx-build -b html -d _build/doctrees . _build/html
106
- Running Sphinx v1.8.5
107
- ...
108
- checking consistency... /path/to/file.rst: WARNING: document isn't included in any toctree
109
- done
110
- ...
111
- build finished with problems, 1 warning.
97
+ .. TODO: Create a "generic" tab?
112
98
113
- You can make all Sphinx warnings into errors during your build process
114
- by setting ``SPHINXOPTS = -W --keep-going `` in your Sphinx Makefile.
99
+ .. tabs ::
115
100
101
+ .. tab :: Sphinx
116
102
117
- Avoid uncrawlable content
118
- ~~~~~~~~~~~~~~~~~~~~~~~~~
103
+ Sphinx calls pages that don't have links to them "orphans"
104
+ and will throw a warning while building documentation that contains an orphan
105
+ unless the warning is silenced with the :ref: `orphan directive <sphinx:metadata >`.
106
+
107
+ We recommend failing your builds whenever Sphinx warns you,
108
+ using the ``fail_on_warnings `` option in :ref: `.readthedocs.yaml <config-file/v2:sphinx >`.
109
+
110
+ Here is an example of a warning of an unreferenced page::
111
+
112
+ $ make html
113
+ sphinx-build -b html -d _build/doctrees . _build/html
114
+ Running Sphinx v1.8.5
115
+ ...
116
+ checking consistency... /path/to/file.rst: WARNING: document isn't included in any toctree
117
+ done
118
+ ...
119
+ build finished with problems, 1 warning.
120
+
121
+ .. tab :: MkDocs
122
+
123
+ MkDocs automatically includes all ``.md `` files in the main navigation 💯️.
124
+ This makes sure that all files are discoverable by default,
125
+ however there are configurations that allow for unlinked files in various ways.
126
+ If you want to scan your documentation for unreferenced files and images,
127
+ a plugin like `mkdocs-unused-files `_ does the job.
128
+
129
+
130
+ .. _mkdocs-unused-files : https://github.com/wilhelmer/mkdocs-unused-files
131
+
132
+
133
+ Avoid uncrawlable content ✅️
134
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
119
135
120
136
While typically this isn't a problem with technical documentation,
121
137
try to avoid content that is "hidden" from search engines.
@@ -125,20 +141,49 @@ For example, if you do have a video in your docs,
125
141
make sure the rest of that page describes the content of the video.
126
142
127
143
When using images, make sure to set the image alt text or set a caption on figures.
128
- For Sphinx, the image and figure directives support this:
129
144
130
- .. sourcecode :: rst
145
+ .. TODO: Create a "generic" tab?
146
+
147
+ .. tabs ::
148
+
149
+ .. tab :: Sphinx
131
150
132
- .. image :: your-image.png
133
- :alt: A description of this image
151
+ For Sphinx, the image and figure directives support both alt texts and captions:
134
152
135
- .. figure :: your-image.png
153
+ .. code-block :: rst
136
154
137
- A caption for this figure
155
+ .. image:: your-image.png
156
+ :alt: A description of this image
138
157
158
+ .. figure:: your-image.png
139
159
140
- Redirects
141
- ~~~~~~~~~
160
+ A caption for this figure
161
+
162
+ .. tab :: MkDocs
163
+
164
+ The Markdown syntax defines an alt text for images:
165
+
166
+ .. code-block :: md
167
+
168
+ { width="300" }
169
+
170
+ Though HTML supports figures and captions,
171
+ Markdown and MkDocs do not have a built-in feature.
172
+ Instead,
173
+ you can use markdown extensions such as `md-in-html `_ to allow the necessary HTML structures for including figures:
174
+
175
+ .. code-block :: md
176
+
177
+ <figure markdown>
178
+ { width="300" }
179
+ <figcaption>Image caption</figcaption>
180
+ </figure>
181
+
182
+ .. _md-in-html : https://python-markdown.github.io/extensions/md_in_html/
183
+
184
+
185
+ Redirects ✅️
186
+ ~~~~~~~~~~~~~
142
187
143
188
Redirects tell search engines when content has moved.
144
189
For example, if this guide moved from ``guides/technical-docs-seo-guide.html `` to ``guides/sphinx-seo-guide.html ``,
@@ -152,8 +197,8 @@ that should cover all the different cases such as redirecting a certain page for
152
197
or redirecting one version to another.
153
198
154
199
155
- Canonical URLs
156
- ~~~~~~~~~~~~~~
200
+ Canonical URLs ✅️
201
+ ~~~~~~~~~~~~~~~~~~
157
202
158
203
Anytime very similar content is hosted at multiple URLs,
159
204
it is pretty important to set a canonical URL.
@@ -167,8 +212,8 @@ under :guilabel:`Admin` > :guilabel:`Domains`
167
212
in the Read the Docs dashboard.
168
213
169
214
170
- Use a robots.txt file
171
- ~~~~~~~~~~~~~~~~~~~~~
215
+ Use a robots.txt file ✅️
216
+ ~~~~~~~~~~~~~~~~~~~~~~~~~
172
217
173
218
A ``robots.txt `` file is readable by crawlers
174
219
and lives at the root of your site (eg. https://docs.readthedocs.io/robots.txt).
@@ -186,8 +231,8 @@ See the `Google's documentation on robots.txt <https://support.google.com/webmas
186
231
for additional details.
187
232
188
233
189
- Use a sitemap.xml file
190
- ~~~~~~~~~~~~~~~~~~~~~~
234
+ Use a sitemap.xml file ✅️
235
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~
191
236
192
237
A sitemap is a file readable by crawlers that contains a list of pages
193
238
and other files on your site and some metadata or relationships about them
@@ -202,8 +247,8 @@ We have a small separate guide on :ref:`sitemaps <hosting:Sitemaps>`.
202
247
See the `Google docs on building a sitemap <https://support.google.com/webmasters/answer/183668 >`_.
203
248
204
249
205
- Use meta tags
206
- ~~~~~~~~~~~~~
250
+ Use meta tags ✅️
251
+ ~~~~~~~~~~~~~~~~~
207
252
208
253
Using a meta description allows you to customize how your pages
209
254
look in search engine result pages.
0 commit comments