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.
This commit is contained in:
parent
f7895dc2fe
commit
eb4d670ee0
6
app.py
6
app.py
@ -248,7 +248,7 @@ def generate_sitemap():
|
|||||||
static_routes = ["/"] # Add your static routes here
|
static_routes = ["/"] # Add your static routes here
|
||||||
for route in static_routes:
|
for route in static_routes:
|
||||||
url = ET.SubElement(urlset, "url")
|
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, "lastmod").text = datetime.fromtimestamp(latest_mtime).strftime("%Y-%m-%d")
|
||||||
ET.SubElement(url, "changefreq").text = "monthly"
|
ET.SubElement(url, "changefreq").text = "monthly"
|
||||||
ET.SubElement(url, "priority").text = "0.8"
|
ET.SubElement(url, "priority").text = "0.8"
|
||||||
@ -257,7 +257,7 @@ def generate_sitemap():
|
|||||||
tags, scales = load_all_scales()
|
tags, scales = load_all_scales()
|
||||||
for tag in tags:
|
for tag in tags:
|
||||||
url = ET.SubElement(urlset, "url")
|
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, "lastmod").text = datetime.fromtimestamp(latest_mtime).strftime("%Y-%m-%d")
|
||||||
ET.SubElement(url, "changefreq").text = "weekly"
|
ET.SubElement(url, "changefreq").text = "weekly"
|
||||||
ET.SubElement(url, "priority").text = "0.6"
|
ET.SubElement(url, "priority").text = "0.6"
|
||||||
@ -265,7 +265,7 @@ def generate_sitemap():
|
|||||||
# Add dynamic scale routes
|
# Add dynamic scale routes
|
||||||
for scale_id in scales.keys():
|
for scale_id in scales.keys():
|
||||||
url = ET.SubElement(urlset, "url")
|
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
|
# For individual scale pages, use the actual file modification time
|
||||||
scale_file = os.path.join('scales', f"{scale_id}.yaml")
|
scale_file = os.path.join('scales', f"{scale_id}.yaml")
|
||||||
if os.path.exists(scale_file):
|
if os.path.exists(scale_file):
|
||||||
|
Loading…
x
Reference in New Issue
Block a user