Improve description tag generation

This commit is contained in:
rubenwardy
2023-04-30 00:53:55 +01:00
parent c2ab4ac308
commit 9fa42df385
8 changed files with 50 additions and 34 deletions

View File

@@ -4,16 +4,20 @@
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>{% block title %}title{% endblock %} - {{ config.USER_APP_NAME }}</title>
<title>{{ self.title() | normalize_whitespace }} - {{ config.USER_APP_NAME }}</title>
<link rel="stylesheet" type="text/css" href="/static/libs/bootstrap.min.css">
<link rel="stylesheet" type="text/css" href="/static/custom.css?v=38">
<link rel="search" type="application/opensearchdescription+xml" href="/static/opensearch.xml" title="ContentDB" />
<link rel="shortcut icon" href="/favicon-16.png" sizes="16x16">
<link rel="icon" href="/favicon-128.png" sizes="128x128">
<link rel="icon" href="/favicon-32.png" sizes="32x32">
{% if noindex %}
<meta name="robots" content="noindex">
{% endif %}
{% if noindex -%}
<meta name="robots" content="noindex">
{%- endif %}
{% if self.description -%}
<meta name="description" content="{{ self.description() | normalize_whitespace }}">
<meta name="og:description" content="{{ self.description() | normalize_whitespace }}">
{%- endif %}
{% block headextra %}{% endblock %}
</head>
<body>

View File

@@ -9,12 +9,6 @@
{{ _("Donations are a great way to support your favorite modders, artists, and game developers.") }}
{% endblock %}
{% block headextra %}
<meta name="og:title" content="{{ self.title() }}">
<meta name="og:description" content="{{ self.description() | replace('\n', ' ') }}">
<meta name="description" content="{{ self.description() | replace('\n', ' ') }}">
{% endblock %}
{% macro authorlink(author) %}
<a href="{{ url_for('users.profile', username=author.username) }}">
{{ author.display_name }}

View File

@@ -4,6 +4,10 @@
{{ _("Welcome") }}
{% endblock %}
{% block description %}
{{ _("Welcome to the best place to find Minetest mods, games, and texture packs") }}
{% endblock %}
{% block scriptextra %}
<script type="application/ld+json">
{

View File

@@ -5,12 +5,11 @@
{{ _('%(title)s by %(author)s', title=package.title, author=package.author.display_name) }}
{% endblock %}
{% block description -%}
{{ _('Mods and texture packs for %(title)s', title=package.title) }}
{% endblock %}
{% block headextra %}
<meta name="og:title" content="{{ self.title() }}"/>
<meta name="og:description" content="{{ _('Mods for %(title)s', title=package.title) }}"/>
<meta name="description" content="{{ _('Mods for %(title)s', title=package.title) }}"/>
<meta name="og:url" content="{{ package.getURL('packages.game_hub', absolute=True) }}"/>
{% if package.getThumbnailURL(3, True) %}
<meta name="og:image" content="{{ package.getThumbnailURL(3, True) }}"/>
{% endif %}

View File

@@ -4,14 +4,14 @@
{{ package.title }}
{% endblock %}
{% block description -%}
{{ package.short_desc }}
{% endblock %}
{% block headextra %}
<meta name="og:title" content="{{ package.title }}"/>
<meta name="og:description" content="{{ package.short_desc }}"/>
<meta name="description" content="{{ package.short_desc }}"/>
<meta name="og:url" content="{{ package.getURL("packages.view", absolute=True) }}"/>
{% if package.getThumbnailURL(3, True) %}
<meta name="og:image" content="{{ package.getThumbnailURL(3, True) }}"/>
{% endif %}
{% if package.getThumbnailURL(3, True) -%}
<meta name="og:image" content="{{ package.getThumbnailURL(3, True) }}"/>
{%- endif %}
{% endblock %}
{% block content %}

View File

@@ -7,14 +7,14 @@
{{ package.title }}
{% endblock %}
{% block description -%}
{{ package.short_desc }}
{% endblock %}
{% block headextra %}
<meta name="og:title" content="{{ package.title }}"/>
<meta name="og:description" content="{{ package.short_desc }}"/>
<meta name="description" content="{{ package.short_desc }}"/>
<meta name="og:url" content="{{ package.getURL("packages.view", absolute=True) }}"/>
{% if package.getThumbnailURL(3, True) %}
<meta name="og:image" content="{{ package.getThumbnailURL(3, True) }}"/>
{% endif %}
{% if package.getThumbnailURL(3, True) -%}
<meta name="og:image" content="{{ package.getThumbnailURL(3, True) }}"/>
{%- endif %}
{% endblock %}
{% block scriptextra %}

View File

@@ -17,11 +17,11 @@
{%- endif -%}
{% endblock %}
{% block description -%}
{{ thread.get_description() }}
{%- endblock %}
{% block headextra %}
<meta name="og:title" content="{{ self.title() }}"/>
<meta name="og:description" content="{{ thread.get_description() }}"/>
<meta name="description" content="{{ thread.get_description() }}"/>
<meta name="og:url" content="{{ thread.getViewURL(absolute=True) }}"/>
<meta name="og:image" content="{{ thread.author.getProfilePicURL() }}"/>
{% endblock %}