Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add custom robots.txt to block indexing /user and AI bots #55

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions ckanext/openafrica/blueprint.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from flask import Blueprint
from flask import Blueprint, make_response
from ckan.plugins.toolkit import render

openafrica = Blueprint("openafrica", __name__)
Expand All @@ -9,14 +9,21 @@ def render_path():

return render_path

def robots_txt():
'''display robots.txt'''
resp = make_response(render("robots.txt"))
resp.headers["Content-Type"] = "text/plain; charset=utf-8"
return resp

rules = [
("/about/terms-and-conditions", "toc", static_path("home/about/toc.html")),
("/about/accessibility", "accessibility", static_path("home/about/accessibility.html")),
("/about/code-of-conduct", "coc", static_path("home/about/coc.html")),
("/about/moderation-policy", "moderation", static_path("home/about/moderation.html")),
("/about/faq", "faq", static_path("home/about/faq.html")),
("/about/privacy", "privacy", static_path("home/about/privacy.html")),
("/about/contact-us", "contact", static_path("home/about/contact.html"))
("/about/contact-us", "contact", static_path("home/about/contact.html")),
("/robots.txt", robots_txt)
]

for rule in rules:
Expand Down
78 changes: 78 additions & 0 deletions ckanext/openafrica/templates/robots.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
# Crawl-delay Specifies the minimum interval (in seconds)
#for a robot to wait after loading one page, before starting to load another.
Crawl-delay: 10

# Disallow specifies the paths that are not allowed to be crawled by the robot.
User-agent: *
Disallow: /dataset/rate/
Disallow: /revision/
Disallow: /dataset/*/history
Disallow: /api/
Disallow: /user/

# Amazonbot
User-agent: Amazonbot
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comparing to other sites, we may be missing some crawlers
The Guardian, Washington Post, BBC, etc.

Disallow: /

# anthropic-ai
User-agent: anthropic-ai
Disallow: /

# Applebot
User-agent: Applebot
Disallow: /

# Applebot-Extended
User-agent: Applebot-Extended
Disallow: /

# Bytespider
User-agent: Bytespider
Disallow: /

# CCBot
User-agent: CCBot
Disallow: /

# ChatGPT-User
User-agent: ChatGPT-User
Disallow: /

# Claude-Web
User-agent: Claude-Web
Disallow: /

# ClaudeBot
User-agent: ClaudeBot
Disallow: /

# cohere-ai
User-agent: cohere-ai
Disallow: /

# Diffbot
User-agent: Diffbot
Disallow: /

# FacebookBot
User-agent: FacebookBot
Disallow: /

# Google-Extended
User-agent: Google-Extended
Disallow: /

# GPTBot
User-agent: GPTBot
Disallow: /

# omgili
User-agent: omgili
Disallow: /

# PerplexityBot
User-agent: PerplexityBot
Disallow: /


# Generatedy by RoboShield (https://roboshield.trustlab.africa)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

RoboShield FTW!

Loading