Skip to content

Instantly share code, notes, and snippets.

@marcospinello
Forked from budparr/robots.txt
Created April 11, 2016 07:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save marcospinello/9705de586b4f27ba562294f4a61cf59a to your computer and use it in GitHub Desktop.
Save marcospinello/9705de586b4f27ba562294f4a61cf59a to your computer and use it in GitHub Desktop.
Jekyll Robots page to exclude from robots pages that are excluded from the sitemap
---
layout: null
permalink: robots.txt
---
# filter pages and documents for the noindex key
{% assign noindexPages = site.pages | where: 'sitemap', false %}
{% assign noindexDocuments = site.documents | where: 'sitemap', false %}
User-agent: *
# robotstxt.org - if _config production variable is false robots will be disallowed.
{% if site.production != true %}
Disallow: /
{% else %}
{% if noindexDocuments or noindexPages %}
{% for node in noindexPages %}
Disallow: {{ node.url }}
{% endfor %}
{% for node in noindexDocuments %}
Disallow: {{ node.url }}
{% endfor %}
{% else %}
Disallow:
{% endif %}
{% endif %}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment