Search code examples
pythonhtmlpython-sphinxrestructuredtext

How can an RST file be excluded from Sphinx's default search?


In a Sphinx project written using RST, is there a way to exclude a file from consideration by the default search functionality? Some of the RST files in the project are included as reference (such as LICENSE files), but are not useful in the search results.

Is there a configuration option or directive that instructs Sphinx not to index a particular RST file for inclusion in the search results?


Solution

  • If you add :nosearch: at the top of the RST file, it will be excluded from the full text search.

    This feature was added in Sphinx 3.0. See https://www.sphinx-doc.org/en/master/usage/restructuredtext/field-lists.html#special-metadata-fields.