Skip to content

Use environment variable to control indexing of rendered docs #15664

@jeremystretch

Description

@jeremystretch

Proposed Changes

When the NetBox documentation is rendered using mkdocs, we ensure that indexing by search engines is disabled unless it has been built for ReadTheDocs. This is done to avoid search engines accidentally caching the local documentation served by publicly-exposed NetBox deployments in the wild, which taints search results.

This is currently accomplished by checking that the page.canonical_url context variable is set to docs.netbox.dev:

{% if page.canonical_url != 'https://docs.netbox.dev/' %}
<meta name="robots" content="noindex">
{% endif %}

This approach is taken because ReadTheDocs currently does not support the use of environment variables within mkdocs configuration files. However, per this recent blog post, support for referencing environment variables will be introduced on April 15. (See also this comment.)

I've opened this issue to track the switch to using an environment variable instead of the context variable (essentially reverting efd8652).

Justification

The environment approach is more flexible as it more customizable and does not rely on an exact string match.

Metadata

Metadata

Assignees

Labels

status: acceptedThis issue has been accepted for implementationtype: housekeepingChanges to the application which do not directly impact the end user

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions