1 # Pleroma: A lightweight social networking server
2 # Copyright © 2017-2022 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 Mix.Pleroma.start_pleroma()
22 static_dir = Pleroma.Config.get([:instance, :static_dir], "instance/static/")
24 if !File.exists?(static_dir) do
25 File.mkdir_p!(static_dir)
28 robots_txt_path = Path.join(static_dir, "robots.txt")
29 robots_txt_content = "User-Agent: *\nDisallow: /\n"
31 File.write!(robots_txt_path, robots_txt_content, [:write])