1 # Pleroma: A lightweight social networking server
2 # Copyright © 2019 Pleroma Authors <https://pleroma.social/>
3 # SPDX-License-Identifier: AGPL-3.0-only
5 defmodule Mix.Tasks.Pleroma.RobotsTxt do
8 @shortdoc "Generate robots.txt"
12 ## Overwrite robots.txt to disallow all
14 mix pleroma.robots_txt disallow_all
16 This will write a robots.txt that will hide all paths on your instance
17 from search engines and other robots that obey robots.txt
20 def run(["disallow_all"]) do
21 static_dir = Pleroma.Config.get([:instance, :static_dir], "instance/static/")
23 if !File.exists?(static_dir) do
24 File.mkdir_p!(static_dir)
27 robots_txt_path = Path.join(static_dir, "robots.txt")
28 robots_txt_content = "User-Agent: *\nDisallow: /\n"
30 File.write!(robots_txt_path, robots_txt_content, [:write])