generate a robots.txt file that blocks search engines if not prod site (#4919)

This commit is contained in:
Paulus Schoutsen 2018-03-14 16:57:55 -07:00 committed by GitHub
parent 39488b0919
commit 06d3f4d0b3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -60,6 +60,13 @@ task :generate do
abort("Generating CSS failed") unless success abort("Generating CSS failed") unless success
success = system "jekyll build" success = system "jekyll build"
abort("Generating site failed") unless success 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 end
desc "Watch the site and regenerate when it changes" desc "Watch the site and regenerate when it changes"