Skip to content

Commit 83a294e

Browse files
Docs: Relabel SEO guide as explanation (Diátaxis) (#10004)
* Transform the guide into an explanation with best practices, use Sphinx and MkDocs examples in tabs * Apply suggestions from @ericholscher's code review Co-authored-by: Eric Holscher <[email protected]> * Re-add motivational text with a reference to the best practices.. but can't be **bold** because reST * Finish the sentence * General intro to unlinked pages * Add TODO items * Apply suggestions from @ericholscher's code review Co-authored-by: Eric Holscher <[email protected]> --------- Co-authored-by: Eric Holscher <[email protected]>
1 parent 2b720ee commit 83a294e

File tree

4 files changed

+108
-59
lines changed

4 files changed

+108
-59
lines changed

docs/user/glossary.rst

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,10 @@ so that you have a reference for how we're using them.
1414
Projects have a *default version*, usually the latest stable version of a project.
1515
The *default version* is the URL that is redirected to when a users loads the `/` URL for your project.
1616

17+
discoverability
18+
A documentation page is said to be *discoverable* when a user that needs it can find it through various methods:
19+
Navigation, search, and links from other pages are the most typical ways of making content *discoverable*.
20+
1721
Docs as Code
1822
A term used to describe the workflow of keeping documentation in a Git repository,
1923
along with source code.

docs/user/guides/administrators.rst

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ have a look at our :doc:`/tutorial/index`.
1616
Connect your Read the Docs account to your Git repository <connecting-git-account>
1717
Manage Custom Domains <custom-domains>
1818
Enable Canonical URLs <canonical-urls>
19-
technical-docs-seo-guide
2019
Use traffic analytics </analytics>
2120
manage-translations-sphinx
2221
hiding-a-version

docs/user/guides/technical-docs-seo-guide.rst

Lines changed: 103 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,29 @@
1-
Technical Documentation Search Engine Optimization (SEO) Guide
2-
==============================================================
1+
Search Engine Optimization (SEO) for documentation projects
2+
===========================================================
33

44
.. meta::
55
:description lang=en:
6-
Looking to optimize your Sphinx documentation for search engines?
6+
Looking to optimize your documentation project for search engines?
77
This SEO guide will help your docs be better understood by both people and crawlers
88
as well as help you rank higher in search engine results.
99

10+
This article explains how documentation can be optimized to appear in search results,
11+
ultimately increasing traffic to your docs.
1012

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,
1414
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.
1816

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.
2320

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::
2822

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.
3427

3528

3629
SEO Basics
@@ -80,8 +73,8 @@ generates static HTML and the performance is typically decent
8073
relative to most of the internet.
8174

8275

83-
Optimizing your docs for search engine spiders
84-
----------------------------------------------
76+
Best practices for documentation SEO
77+
------------------------------------
8578

8679
Once a crawler or spider finds your site, it will follow links and redirects
8780
in an attempt to find any and all pages on your site.
@@ -92,30 +85,53 @@ which we'll discuss shortly,
9285
the most important thing is making sure the spider can follow links on your site
9386
and get to all your pages.
9487

95-
Avoid orphan pages
96-
~~~~~~~~~~~~~~~~~~
88+
Avoid unlinked pages ✅️
89+
~~~~~~~~~~~~~~~~~~~~~~~~
9790

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.
10194

102-
::
95+
Search engine crawlers will not discover pages that aren't linked from somewhere else on your site.
10396

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?
11298
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::
115100

101+
.. tab:: Sphinx
116102

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+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
119135

120136
While typically this isn't a problem with technical documentation,
121137
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,
125141
make sure the rest of that page describes the content of the video.
126142

127143
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:
129144

130-
.. sourcecode:: rst
145+
.. TODO: Create a "generic" tab?
146+
147+
.. tabs::
148+
149+
.. tab:: Sphinx
131150

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:
134152

135-
.. figure:: your-image.png
153+
.. code-block:: rst
136154
137-
A caption for this figure
155+
.. image:: your-image.png
156+
:alt: A description of this image
138157
158+
.. figure:: your-image.png
139159
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+
![Image alt text](https://dummyimage.com/600x400/){ 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+
![Image alt text](https://dummyimage.com/600x400/){ 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+
~~~~~~~~~~~~~
142187

143188
Redirects tell search engines when content has moved.
144189
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
152197
or redirecting one version to another.
153198

154199

155-
Canonical URLs
156-
~~~~~~~~~~~~~~
200+
Canonical URLs ✅️
201+
~~~~~~~~~~~~~~~~~~
157202

158203
Anytime very similar content is hosted at multiple URLs,
159204
it is pretty important to set a canonical URL.
@@ -167,8 +212,8 @@ under :guilabel:`Admin` > :guilabel:`Domains`
167212
in the Read the Docs dashboard.
168213

169214

170-
Use a robots.txt file
171-
~~~~~~~~~~~~~~~~~~~~~
215+
Use a robots.txt file ✅️
216+
~~~~~~~~~~~~~~~~~~~~~~~~~
172217

173218
A ``robots.txt`` file is readable by crawlers
174219
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
186231
for additional details.
187232

188233

189-
Use a sitemap.xml file
190-
~~~~~~~~~~~~~~~~~~~~~~
234+
Use a sitemap.xml file ✅️
235+
~~~~~~~~~~~~~~~~~~~~~~~~~~
191236

192237
A sitemap is a file readable by crawlers that contains a list of pages
193238
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>`.
202247
See the `Google docs on building a sitemap <https://support.google.com/webmasters/answer/183668>`_.
203248

204249

205-
Use meta tags
206-
~~~~~~~~~~~~~
250+
Use meta tags ✅️
251+
~~~~~~~~~~~~~~~~~
207252

208253
Using a meta description allows you to customize how your pages
209254
look in search engine result pages.

docs/user/index.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,7 @@ to help you create fantastic documentation for your project.
8888
/science
8989
/commercial/organizations
9090
/automatic-redirects
91+
/guides/technical-docs-seo-guide
9192

9293
.. toctree::
9394
:maxdepth: 2

0 commit comments

Comments
 (0)