Skip to content

Commit

Permalink
feature(templates): améliore la gestio du type de page et ajoute un s…
Browse files Browse the repository at this point in the history
…chéma spécifique pour les pages de profils des auteur/ices (#1119)

Voir
https://developers.google.com/search/docs/appearance/structured-data/profile-page?hl=fr
  • Loading branch information
Guts authored May 9, 2024
2 parents eb82b3d + 2826ad9 commit 7c3b8f5
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 5 deletions.
14 changes: 11 additions & 3 deletions content/theme/main.html
Original file line number Diff line number Diff line change
Expand Up @@ -65,13 +65,17 @@
<meta http-equiv="expires" content="43200" />

{# Meta type #}
{% set page_type = "article" %}
{% if page.is_homepage or page.abs_url == "/" %}
{% set type = "website" %}
{% set page_type = "website" %}
{% elif "rdp/" in page.url %}
{% set page_type = "geordp" %}
{% elif "team/" in page.url %}
{% set page_type = "author_profile" %}
{% else %}
{% set type = "article" %}
{% set page_type = "article" %}
{% endif %}

<meta name="social:card" content="{{ social_card }}">
{# JSON Feed #}
{% include "partials/json_feed.html.jinja2" %}
{# Semantic web - schemas.org #}
Expand All @@ -81,6 +85,10 @@
{# Social cards - Twitter #}
{% include "partials/cards_twitter.html.jinja2" %}

{# Store custom Geotribu tags #}
<meta name="geotribu:page_type" content="{{ page_type }}">
<meta name="social:card" content="{{ social_card }}">

{% endblock %}


Expand Down
18 changes: 16 additions & 2 deletions content/theme/partials/schemas.html.jinja2
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{# Structured data using schema.org #}
{% if type == "article" %}
{% if page_type in ("article", "geordp") %}
<script type="application/ld+json">
{
"@context": "https://schema.org",
Expand Down Expand Up @@ -73,7 +73,21 @@
}
}
</script>
{% elif type == "website" %}
{% elif page_type == "author_profile" %}
<script type='application/ld+json'>
{
"@context": "http://www.schema.org",
"@type": "ProfilePage",
"dateCreated": "{{ page_date }}T13:00:00Z",
"dateModified": "{{ build_date_utc.isoformat() }}",
"mainEntity": {
"@type": "Person",
"name": "{{ page.title }}",
{% if page.meta.subtitle %}"alternateName": "{{ page.meta.subtitle }}",{% endif %}
}
}
</script>
{% elif page_type == "website" %}
<script type='application/ld+json'>
{
"@context": "http://www.schema.org",
Expand Down

0 comments on commit 7c3b8f5

Please sign in to comment.