From 06d3f4d0b31f355ab5e4875150f13ecaa6ce2e85 Mon Sep 17 00:00:00 2001 From: Paulus Schoutsen Date: Wed, 14 Mar 2018 16:57:55 -0700 Subject: [PATCH] generate a robots.txt file that blocks search engines if not prod site (#4919) --- Rakefile | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/Rakefile b/Rakefile index e44380c49dc..c56c918561c 100644 --- a/Rakefile +++ b/Rakefile @@ -60,6 +60,13 @@ task :generate do abort("Generating CSS failed") unless success success = system "jekyll build" abort("Generating site failed") unless success + if ENV["CONTEXT"] != 'production' + File.open("#{public_dir}robots.txt", 'w') do |f| + f.write "User-agent: *\n" + f.write "Disallow: /\n" + end + end + public_dir end desc "Watch the site and regenerate when it changes"