uchicago-library / library_website

The University of Chicago Library Website
5 stars 5 forks source link

Exclude Pages From Indexing and Search #764

Closed bbusenius closed 3 months ago

bbusenius commented 4 months ago

ILL needs a new payment form. As part of the spec for this form, the page should not be discoverable in search engines, however, when thinking this through, there are probably three things we need:

  1. The ability to exclude pages from search results.
  2. The ability to exclude pages from site search in the Wagtail site.
  3. The ability to exclude pages from the Google sitemap.xml.

We can create Boolean fields in the Page model for each of the above so that their behavior is controlled separately. We can exclude pages from search engine indexing by displaying the <meta name="robots" content="noindex" /> in the templates if the related exclude field is set. We can exclude pages from Wagtail site search by filtering the QuerySet in results/views.py using Django's exclude filter. Pages can be suppressed from the sitemap by defining a get_sitemap_urls on the Page model in a fashion similar to this.