Files
docker-docs/js/metadata.json
Sebastiaan van Stijn 03d60f916a Replace "hide_from_sitemap" with "sitemap: false"
The `hide_from_sitemap` metadata variable was a custom thing we implemented
to add a "noindex" meta-header to pages and to exclude a page from the
search auto-complete.

However, pages with that option set would still be included in sitemap.xml,
resulting in search engines to visit those pages (only to discover they
should not index them).

This patch replaces the custom `hide_from_sitemap` value for `sitemap: false`,
which is a metadata variable that's defined by the "jekyll-sitemap" plugin
we use to generate the sitemap.xml;

https://github.com/jekyll/jekyll-sitemap/blob/v1.4.0/README.md#exclusions

Setting this variable will now:

- add a "noindex" metadata header to the page
- exclude the page from the sitemap.xml.
- exclude the page from /js/metadata.json (used for search autocomplete)

Also fixed an issue in the metadata.json where the `notoc` metadata was
used to exclude pages, however that variable is meant to disable the
in-page TOC (right-hand side navigation with anchor links).

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2020-10-21 15:09:11 +02:00

31 lines
1.6 KiB
JSON

---
layout: null
---
[
{%- for page in site.html_pages -%}
{%- if page.sitemap == false -%}
{%- continue -%}
{%- endif -%}
{%- assign page_title = nil -%}
{%- assign page_description = nil -%}
{%- if page.title == nil and page.content and page.content contains '<h1' -%}
{%- assign a = page.content | split: '<h1' | last -%}
{%- assign b = a | split: '</h1' | first -%}
{%- assign c = b | split: '>' | last -%}
{%- assign page_title = c | strip_html | strip | truncatewords: 10 -%}
{%- endif -%}
{%- if page.description == nil and page.datafile != nil and page.datafile != '' -%}
{%- assign yaml_data = site.data[page.datafolder][page.datafile] -%}
{%- if yaml_data.long and yaml_data.long != '' -%}
{%- assign page_description = page.title | append: ': ' | append: yaml_data.long | strip_html | strip | truncatewords: 30 -%}
{%- elsif yaml_data.short and yaml_data.short != '' -%}
{%- assign page_description = page.title | append: ': ' | append: yaml_data.short | strip_html | strip | truncatewords: 30 -%}
{%- elsif page.content and page.content != '' -%}
{%- assign page_description = page.content | strip_html | strip | truncatewords: 30 -%}
{%- endif -%}
{%- endif -%}
{%- if page.title == nil and page_title == nil -%}{%- continue -%}{%- endif %}
{"url":{{ page.url | jsonify }},"title":{{ page.title | default: page_title | jsonify }},"description":{{ page.description | default: page_description | jsonify }},"keywords":{{ page.keywords | jsonify }}},
{%- endfor %}
{}]