You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

56 lines
2.6 KiB

4 years ago
  1. +++
  2. title = "Index Blocking"
  3. description = "Define pages to prevent them from appearing in search."
  4. categories = ["search"]
  5. tags = ["links", "search", "robots", "metadata"]
  6. features = ["code highlighter", "related content", "snippets"]
  7. [[copyright]]
  8. owner = "Josh Habdas"
  9. date = "2019"
  10. license = "agpl-3.0-or-later"
  11. +++
  12. After Dark uses the `noindex` robots meta directive to prevent search engines from crawling and indexing certain parts of your site. It appears in the HTML document `head` and looks like this:
  13. ```html
  14. <meta name="robots" content="noindex">
  15. ```
  16. Unlike {{< external href="http://www.robotstxt.org" text="robots.txt" />}} meta directives are defined within page content itself and unambiguously indicate which, if any, pages should be blocked from indexing — even if some of those pages appear in your site's {{< external href="https://gohugo.io/templates/sitemap-template/" text="Sitemap" />}}.
  17. To facilitate the discovery of index blocked pages [Fuzzy Search](../fuzzy-search) utilizes the very same meta directive exposed to search engines to prevent disclosure of pages in its own result listings. Therefore, if a page can be found in fuzzy search, that page may ultimately appear on a search engine result page.
  18. Adjust index blocking per-page using `noindex` {{< external href="https://gohugo.io/content-management/front-matter/" text="Front Matter" />}}:
  19. ```toml
  20. noindex = true # set false or remove to unblock
  21. ```
  22. Block entire sections using an `_index.md` file with the above setting:
  23. ```
  24. ├── content
  25. │ ├── legal
  26. │ │ ├── _index.md
  27. │ │ ├── terms.md
  28. │ │ └── privacy.md
  29. │ ├── post
  30. ```
  31. By default the following page types are blocked automatically:
  32. - Section listings automatically linked to from the [Section Menu](../section-menu);
  33. - [Taxonomy Pages](../taxonomy-pages) such as `Category`, `Tag` and terms listings; and,
  34. - If enabled, the [Fuzzy Search](../fuzzy-search) page or any deep-linked result within.
  35. Adjust defaults using the `noindex_kinds` setting from {{< external href="https://gohugo.io/getting-started/configuration/" text="Site Configuration" />}}. For example, to enable crawling of section pages add the following to the config:
  36. ```toml
  37. [params]
  38. noindex_kinds = [
  39. "taxonomy",
  40. "taxonomyTerm"
  41. ] # crawl "section" pages
  42. ```
  43. Learn about {{< external href="https://moz.com/learn/seo/robots-meta-directives" text="Robots Meta Directives on Moz" />}} and see how Google uses `noindex` in {{< external href="https://support.google.com/webmasters/answer/93710" text="Block search indexing with 'noindex'" />}}.