Refactor URL handling to use BASE_URL across the application and add base_url context processor
All checks were successful
Deploy to Server / deploy (push) Successful in 22s

This commit is contained in:
Joakim Hellsén 2026-04-03 19:51:01 +02:00
commit d4fd35769d
Signed by: Joakim Hellsén
SSH key fingerprint: SHA256:/9h/CsExpFp+PRhsfA0xznFx2CGfTT5R/kpuFfUgEQk
11 changed files with 250 additions and 167 deletions

View file

@ -32,7 +32,7 @@
content="{% firstof page_description 'ttvdrops - Track Twitch drops.' %}" />
<meta property="og:type" content="{% firstof og_type 'website' %}" />
<meta property="og:url"
content="{% firstof page_url request.build_absolute_uri %}" />
content="{% if page_url %}{{ page_url }}{% else %}{{ BASE_URL }}{{ request.get_full_path }}{% endif %}" />
{% if page_image %}
<meta property="og:image" content="{{ page_image }}" />
{% if page_image_width and page_image_height %}
@ -41,7 +41,8 @@
{% endif %}
{% endif %}
{# Twitter Card tags for rich previews #}
<meta name="twitter:card" content="{% if page_image %}summary_large_image{% else %}summary{% endif %}" />
<meta name="twitter:card"
content="{% if page_image %}summary_large_image{% else %}summary{% endif %}" />
<meta name="twitter:title" content="{% firstof page_title 'ttvdrops' %}" />
<meta name="twitter:description"
content="{% firstof page_description 'ttvdrops - Twitch and Kick drops.' %}" />
@ -50,20 +51,13 @@
{% if published_date %}<meta property="article:published_time" content="{{ published_date }}" />{% endif %}
{% if modified_date %}<meta property="article:modified_time" content="{{ modified_date }}" />{% endif %}
{# Canonical tag #}
<link rel="canonical" href="{% firstof page_url request.build_absolute_uri %}" />
<link rel="canonical"
href="{% if page_url %}{{ page_url }}{% else %}{{ BASE_URL }}{{ request.get_full_path }}{% endif %}" />
{# Pagination links (for crawler efficiency) #}
{% if pagination_info %}
{% for link in pagination_info %}<link rel="{{ link.rel }}" href="{{ link.url }}" />{% endfor %}
{% endif %}
{# Schema.org JSON-LD structured data #}
{% if schema_data %}
<script type="application/ld+json">
{{ schema_data|safe }}
</script>
{% endif %}
{% if schema_data %}<script type="application/ld+json">{{ schema_data|safe }}</script>{% endif %}
{# Breadcrumb schema #}
{% if breadcrumb_schema %}
<script type="application/ld+json">
{{ breadcrumb_schema|safe }}
</script>
{% endif %}
{% if breadcrumb_schema %}<script type="application/ld+json">{{ breadcrumb_schema|safe }}</script>{% endif %}