Adding robots.tx and a sitemap

Hello -

I host a Dash app on a subdomain of my website for my users to interactively explore community survey data. From what I can tell, search engines treat sub domain’s as their own unique domain. So, I would like to have a robots.txt and a sitemap.xml file available for the craweler.

How can I accomplish this?

Would you recommend hosting the app at example.com/app instead of app.example.com?

Thanks!

Is this possible? I haven’t been able to figure it out.

@cmwetherell aware it’s been a while but don’t suppose you found an answer to this question?

Hello @matt-buckley,

I think I’d honestly just use a Flask template and route to return the info that you want to display.

1 Like

This is how I did it, although it’s a bit late answer, I just want to put the solution here, just in case.

from flask import send_from_directory

@app.server.route("/sitemap.xml")
def send_sitemap():
    return send_from_directory("assets", "sitemap.xml")

@app.server.route("/robots.txt")
def send_robots():
    return send_from_directory("assets", "robots.txt")

4 Likes