Skip to content

Instantly share code, notes, and snippets.

@denstepa
Created March 1, 2016 23:47
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 denstepa/bc4ddea61e5f8d668ef8 to your computer and use it in GitHub Desktop.
Save denstepa/bc4ddea61e5f8d668ef8 to your computer and use it in GitHub Desktop.
capistrano 3 task to update robots.txt for staging
desc "Uploads a robots.txt that mandates the site as off-limits to crawlers"
task :block_robots do
content = [
'# This is a staging site. Do not index.',
'User-agent: *',
'Disallow: /'
].join($/)
on roles(:all) do
within release_path do
puts "Uploading blocking robots.txt"
execute(:echo, "\"#{content}\" > public/robots.txt")
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment