From e989919de01eb5f3a650bc85a55a1de653b1a305 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Paulo=20Carvalho?= Date: Wed, 14 Oct 2026 11:56:29 -0300 Subject: [PATCH] =?UTF-8?q?feat(seo):=20descri=C3=A7=C3=A3o=20do=20evento?= =?UTF-8?q?=20configur=C3=A1vel=20nas=20meta=20tags?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - novo campo event.meta_description em variables.yaml, usado em description, og:description e twitter:description (como no site da PyNE 2025) - fallback para a descrição montada a partir de nome, edição e cidade - teste valida limite de 160 caracteres e presença nas três tags Co-Authored-By: Claude Opus 5.5 --- templates/base.j2 | 8 +++++--- tests/test_site.py | 20 ++++++++++++++++++++ variables.yaml | 3 +++ 3 files changed, 28 insertions(+), 3 deletions(-) diff --git a/templates/base.j2 b/templates/base.j2 index c3354ec..c661553 100644 --- a/templates/base.j2 +++ b/templates/base.j2 @@ -5,6 +5,8 @@ {% set event_city = event.location.city if event and event.location and event.location.city else (city | default('')) %} {% set event_state = event.location.state if event and event.location and event.location.state else (state | default('')) %} {% set event_desc = event.description if event and event.description else (event_description | default('')) %} +{# Descrição curta para buscadores e previews de redes sociais (event.meta_description) #} +{% set event_meta_desc = event.meta_description if event and event.meta_description else (event_name ~ ' ' ~ event_edition ~ ((' em ' ~ event_city ~ ', ' ~ event_state) if event_city else '') ~ '. ' ~ event_desc) %} {% set event_url = event.url if event and event.url else ('https://' ~ event_edition ~ '.pythonnordeste.org/') %} {% set event_preview_image = theme.preview_image if theme and theme.preview_image else (preview_image | default('static/img/logo_pyne2027.png')) %} {# Redes sociais (Facebook, LinkedIn, WhatsApp, X) exigem URL absoluta na og:image #} @@ -28,7 +30,7 @@ - + @@ -47,7 +49,7 @@ - + @@ -65,7 +67,7 @@ - + diff --git a/tests/test_site.py b/tests/test_site.py index 1183cc2..d1c2136 100644 --- a/tests/test_site.py +++ b/tests/test_site.py @@ -143,3 +143,23 @@ def test_social_preview_uses_absolute_image_url(): assert f'name="twitter:image" content="{expected}"' in index_html assert 'property="og:title"' in index_html assert 'name="twitter:card" content="summary_large_image"' in index_html + + +def test_meta_description_used_in_search_and_social_tags(): + settings = load_settings() + meta_description = settings["event"].get("meta_description") + if not meta_description: + pytest.skip("event.meta_description não definido em variables.yaml.") + + assert len(meta_description) <= 160, ( + "event.meta_description deve ter até 160 caracteres para não ser cortada no Google." + ) + + render() + index_html = (output_folder / "index.html").read_text(encoding="utf-8") + for tag in ( + f'name="description" content="{meta_description}"', + f'property="og:description" content="{meta_description}"', + f'name="twitter:description" content="{meta_description}"', + ): + assert tag in index_html, f"Meta tag ausente ou divergente: {tag}" diff --git a/variables.yaml b/variables.yaml index cc165f5..5ef2d49 100644 --- a/variables.yaml +++ b/variables.yaml @@ -4,6 +4,9 @@ event: edition: "2027" # Ex: "2027", "10ª Edição" tagline: "O maior evento de Python do Nordeste agora no litoral do Piauí!" description: "Pessoas > Tecnologia" + # Descrição curta usada nas meta tags (Google, og:description, twitter:description). + # Recomendado: até ~160 caracteres para não ser cortada nos resultados de busca. + meta_description: "Desde 2013, a Python Nordeste inclui pessoas na tecnologia e dissemina Python no Nordeste. Em 2027, o evento acontece em Parnaíba-PI." date: "2027" # Pode ser "15 a 18 de Outubro" ou "Em breve" format: "presencial" # "presencial" ou "online" url: "https://2027.pythonnordeste.org/"