feat: start adding canonical urls

This commit is contained in:
2025-06-29 08:26:26 +02:00
parent 3d2ef9e735
commit 63c692d46b
5 changed files with 10 additions and 1 deletions

View File

@@ -12,6 +12,7 @@
{% block description %}{% endblock %}
{% block og_description %}{% endblock %}
{% block og_image %}{% endblock %}
<link rel="canonical" href="{% block canonical_url %}{% endblock %}">
<!-- Add additional CSS in static file -->
<link rel="stylesheet" href="{% static 'fellchensammlung/css/main.css' %}">

View File

@@ -13,6 +13,7 @@
{% block og_description %}
<meta name="og:description" content="{{ adoption_notice.description }}">
{% endblock %}
{% block canonical_url %}{{ host }}{% url 'adoption-notice-detail' adoption_notice_id=adoption_notice.id %}{% endblock %}
{% block og_image %}
{% if adoption_notice.get_photos %}

View File

@@ -8,7 +8,7 @@
{% block description %}<meta name="description" content="{% translate "notfellchen.org listet Farbratten in Tierheimen und Pflegestellen die ein Zuhause suchen. Adoptieren statt kaufen!" %}">{% endblock %}
{% block og_description %}<meta name="og:description" content="{% translate "notfellchen.org listet Farbratten in Tierheimen und Pflegestellen die ein Zuhause suchen. Adoptieren statt kaufen!" %}">{% endblock %}
{% block og_image %}<meta property="og:image" content="{% static 'fellchensammlung/img/link_preview.png' %}" />{% endblock %}
{% block canonical_url %}{{ host }}{% url 'index' %}{% endblock %}
{% block content %}
{% for announcement in announcements %}

View File

@@ -108,3 +108,8 @@ def trust_level(level_string):
@register.filter
def dictkey(d, key):
return d.get(key)
@register.simple_tag
def host():
return settings.host

View File

@@ -141,6 +141,8 @@ STATIC_ROOT = config.get("locations", "static", fallback="/notfellchen/static")
MEDIA_ROOT = config.get("locations", "media", fallback="/notfellchen/static")
MEDIA_URL = config.get("urls", "media", fallback="/media/")
# Host will be used for allowed hosts but also for canonical URLs and CSRF settings!
# Take all three into account when modifying
host = config.get("notfellchen", "host", fallback='*')
# see https://docs.djangoproject.com/en/3.2/ref/settings/#std-setting-ALLOWED_HOSTS