-
-
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
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--- | |
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