From eb4d670ee0d2294dfeab6bf3878133a4dc850375 Mon Sep 17 00:00:00 2001 From: mxr612 Date: Mon, 16 Jun 2025 17:53:22 +0800 Subject: [PATCH] fix: update sitemap URLs to use the www subdomain - Modified the sitemap generation logic in app.py to prepend 'www.' to the base URL for static routes, tag routes, and scale routes. - This change ensures consistency in URL formatting and improves SEO by standardizing the domain used in the sitemap. --- app.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/app.py b/app.py index d049d5f..c5a7241 100644 --- a/app.py +++ b/app.py @@ -248,7 +248,7 @@ def generate_sitemap(): static_routes = ["/"] # Add your static routes here for route in static_routes: url = ET.SubElement(urlset, "url") - ET.SubElement(url, "loc").text = f"https://psychoscales.org{route}" + ET.SubElement(url, "loc").text = f"https://www.psychoscales.org{route}" ET.SubElement(url, "lastmod").text = datetime.fromtimestamp(latest_mtime).strftime("%Y-%m-%d") ET.SubElement(url, "changefreq").text = "monthly" ET.SubElement(url, "priority").text = "0.8" @@ -257,7 +257,7 @@ def generate_sitemap(): tags, scales = load_all_scales() for tag in tags: url = ET.SubElement(urlset, "url") - ET.SubElement(url, "loc").text = f"https://psychoscales.org/tag/{tag}" + ET.SubElement(url, "loc").text = f"https://www.psychoscales.org/tag/{tag}" ET.SubElement(url, "lastmod").text = datetime.fromtimestamp(latest_mtime).strftime("%Y-%m-%d") ET.SubElement(url, "changefreq").text = "weekly" ET.SubElement(url, "priority").text = "0.6" @@ -265,7 +265,7 @@ def generate_sitemap(): # Add dynamic scale routes for scale_id in scales.keys(): url = ET.SubElement(urlset, "url") - ET.SubElement(url, "loc").text = f"https://psychoscales.org/scales/{scale_id}" + ET.SubElement(url, "loc").text = f"https://www.psychoscales.org/scales/{scale_id}" # For individual scale pages, use the actual file modification time scale_file = os.path.join('scales', f"{scale_id}.yaml") if os.path.exists(scale_file):