fix: remove double language prefix from article URLs

generate_articles() was storing url_path with lang prefix (/en/markets/...)
but the content blueprint is registered at /<lang>, producing double-prefix
URLs like /en/en/markets/italy. Fix: store url_path without prefix, build
full_url with prefix for SEO tags (canonical, OG, hreflang, breadcrumbs).

Also removes /markets from RESERVED_PREFIXES since article sub-paths under
/markets/ are valid pSEO content URLs, not blueprint routes.

Subtask 1 of pSEO template improvements.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
Deeman
2026-02-24 02:01:33 +01:00
parent 90a5ab0451
commit ffe4b111eb
4 changed files with 14 additions and 13 deletions

View File

@@ -69,7 +69,7 @@
{% for a in scorecard %}
<tr>
<td style="max-width:250px">
<a href="{{ a.url_path }}" target="_blank" class="text-sm" title="{{ a.url_path }}">{{ a.title or a.url_path }}</a>
<a href="/{{ a.language or 'en' }}{{ a.url_path }}" target="_blank" class="text-sm" title="{{ a.url_path }}">{{ a.title or a.url_path }}</a>
{% if a.template_slug %}
<br><span class="text-xs text-slate">{{ a.template_slug }}</span>
{% endif %}

View File

@@ -308,8 +308,8 @@ async def generate_articles(
# Build render context: row data + language
ctx = {**row, "language": lang}
# Render URL pattern
url_path = f"/{lang}" + _render_pattern(config["url_pattern"], ctx)
# Render URL pattern (no lang prefix — blueprint provides /<lang>)
url_path = _render_pattern(config["url_pattern"], ctx)
if is_reserved_path(url_path):
continue
@@ -375,8 +375,8 @@ async def generate_articles(
# Extract FAQ pairs for structured data
faq_pairs = _extract_faq_pairs(body_md)
# Build SEO metadata
full_url = base_url + url_path
# Build SEO metadata (full_url includes lang prefix for canonical/OG)
full_url = f"{base_url}/{lang}{url_path}"
publish_dt = datetime(
publish_date.year, publish_date.month, publish_date.day,
8, 0, 0,
@@ -397,7 +397,7 @@ async def generate_articles(
)
# JSON-LD
breadcrumbs = _build_breadcrumbs(url_path, base_url)
breadcrumbs = _build_breadcrumbs(f"/{lang}{url_path}", base_url)
jsonld_objects = build_jsonld(
config["schema_type"],
title=title,
@@ -499,7 +499,7 @@ async def preview_article(
ctx = {**row, "language": lang}
url_path = f"/{lang}" + _render_pattern(config["url_pattern"], ctx)
url_path = _render_pattern(config["url_pattern"], ctx)
title = _render_pattern(config["title_pattern"], ctx)
meta_desc = _render_pattern(config["meta_description_pattern"], ctx)

View File

@@ -23,7 +23,7 @@ BUILD_DIR = Path("data/content/_build")
RESERVED_PREFIXES = (
"/admin", "/auth", "/planner", "/billing", "/dashboard",
"/directory", "/leads", "/suppliers", "/health",
"/sitemap", "/static", "/markets", "/features", "/feedback",
"/sitemap", "/static", "/features", "/feedback",
)
SCENARIO_RE = re.compile(r'\[scenario:([a-z0-9_-]+)(?::([a-z]+))?\]')