Building full-stack web applications with Python and Reflex is already pretty cool. But I recently stumbled upon a neat little feature that makes managing your site's SEO a bit simpler.
If you're deploying your Reflex app to a specific URL, you can add that URL to your rx.config. Here's the interesting part: when Reflex builds your site, it automatically generates both a robots.txt and a sitemap.xml file for you.
Yes, you read that right. No more manually creating these essential SEO files. Reflex takes care of it.
The robots.txt file tells search engine crawlers which pages on your site they should or shouldn't access. The sitemap.xml file, on the other hand, provides a roadmap of all the dynamic routes in your application, helping search engines discover and index your content more effectively.
This automatic generation is triggered as soon as you include the deploy_url in your rx.config.
For instance:
import reflex as rx config = rx.Config( app_name="app", backend_port=8001, frontend_port=3000, loglevel="info", db_url=None, backend_host="127.0.0.1", gunicorn_worker_class="uvicorn.workers.UvicornH11Worker", gunicorn_workers=4, deploy_url="https://davidmuraya.com", )
You can view all the parameters that you can configure in the rx.Config class here.
So, if you're using Reflex and haven't added your deploy_url yet, you might want to consider it. It's a small detail, but it can save you some time and ensure your site is more easily discoverable by search engines. Just another way Reflex makes building web apps a bit smoother.
David Muraya is a Solutions Architect specializing in Python, FastAPI, and Cloud Infrastructure. He is passionate about building scalable, production-ready applications and sharing his knowledge with the developer community. You can connect with him on LinkedIn.
Enjoyed this blog post? Check out these related posts!
Adding Google Authentication to Your FastAPI Application
A guide to adding Google Authentication to your FastAPI app.
Read More..
Slimmer FastAPI Docker Images with Multi-Stage Builds
Understanding Multi-Stage Builds in Docker
Read More..
Running Database Migrations with Alembic in Google Cloud Build
How to Organize and Load FastAPI Settings from a .env File Using Pydantic v2
Read More..
Have a project in mind? Send me an email at hello@davidmuraya.com and let's bring your ideas to life. I am always available for exciting discussions.