Refactoring SEO
This commit is contained in:
@@ -1,72 +1,76 @@
|
||||
{% extends "base.html" %}
|
||||
|
||||
{% block html_lang %}{{ article.lang }}{% endblock %}
|
||||
|
||||
{% block extra_head %}
|
||||
<meta name="author" content="{{ article.author }}">
|
||||
<meta name="keywords" content="{{ article.tags|join(',')|escape }}">
|
||||
{% endblock %}
|
||||
|
||||
{% block extra_comment %}
|
||||
<link href="{{ SITEURL }}/{{ THEME_STATIC_DIR }}/modules/plyr/plyr.css" rel="stylesheet">
|
||||
{% endblock %}
|
||||
|
||||
{% block head %}
|
||||
{% block title %}
|
||||
<title>{{ article.title }} - {{SITENAME}}</title>
|
||||
{% endblock %}
|
||||
{{ super() }}
|
||||
{% import 'translations.html' as translations with context %}
|
||||
{% if translations.entry_hreflang(article) %}
|
||||
{{ translations.entry_hreflang(article) }}
|
||||
{% endif %}
|
||||
<meta property="og:title" content="{{ article.title }}">
|
||||
<meta itemprop="name" content="{{ article.title }}">
|
||||
<meta property="og:type" content="video.movie">
|
||||
<meta property="og:url" content="{{ SITEURL }}/{{ article.url }}">
|
||||
<meta property="video:release_date" content="{{ article.date.isoformat() }}">
|
||||
<meta itemprop="uploadDate" content="{{ article.date.isoformat() }}">
|
||||
{% if article.modified %}
|
||||
<meta property="article:modified_time" content="{{ article.modified.isoformat() }}">
|
||||
{% endif %}
|
||||
<meta property="article:section" content="{{ article.category }}">
|
||||
{% set og_description = article.summary.split(ANOTHER_READ_MORE_LINK_FORMAT[:6])[0][3:]|striptags|escape %}
|
||||
{% set OG_DESC_LENGTH = 175 %}
|
||||
{% if og_description|length >= OG_DESC_LENGTH %}
|
||||
{# Quita la última palabra para no dejarla incompleta #}
|
||||
{% set og_description = og_description[:OG_DESC_LENGTH].split(' ')[:-1]|join(' ') %}
|
||||
{% if not og_description[-1] in ['.', '?', ':', '!'] %}
|
||||
{% set og_description = og_description + '…' %}
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
<meta property="og:description" content="{{ article.summary|striptags|escape }}"/>
|
||||
<meta itemprop="description" content="{{ article.summary|striptags|escape }}"/>
|
||||
{% if article.image %}
|
||||
<meta property="og:image" content="{{ SITEURL }}/{{ THEME_STATIC_DIR }}/../wp-content/uploads/article/poster/{{ article.image }}"/>
|
||||
<meta itemprop="thumbnailURL" content="{{ SITEURL }}/{{ THEME_STATIC_DIR }}/../wp-content/uploads/article/poster/{{ article.image }}">
|
||||
{% elif OPEN_GRAPH_IMAGE %}
|
||||
<meta property="og:image" content="{{ SITEURL }}/{{ OPEN_GRAPH_IMAGE }}"/>
|
||||
{% endif %}
|
||||
<!-- videograph -->
|
||||
{% if article.og_video %}
|
||||
<meta property="og:video" content="{{ article.og_video }}">
|
||||
<meta property="og:video:secure_url" content="{{ article.og_video }}">
|
||||
<meta property="og:video:type" content="video/webm">
|
||||
<meta property="og:video:width" content="400">
|
||||
<meta property="og:video:height" content="300">
|
||||
{% endif %}
|
||||
<!-- /videograph -->
|
||||
{% for tag in article.tags %}
|
||||
<meta property="og:video:tag" content="{{ tag | escape }}">
|
||||
{% endfor %}
|
||||
|
||||
<!-- plyr -->
|
||||
<link href="{{ SITEURL }}/{{ THEME_STATIC_DIR }}/modules/plyr/plyr.css" rel="stylesheet">
|
||||
<!--/ plyr -->
|
||||
{% if article.styles %}
|
||||
{% for style in article.styles %}
|
||||
{{ style }}
|
||||
{% endfor %}
|
||||
{% endif %}
|
||||
|
||||
{% block seo %}
|
||||
{% set seo_description = article.summary|striptags %}
|
||||
{% set SEO_DESC_LENGTH = 175 %}
|
||||
{% if seo_description|length >= SEO_DESC_LENGTH %}
|
||||
{# Quita la última palabra para no dejarla incompleta #}
|
||||
{% set seo_description = seo_description[:SEO_DESC_LENGTH].split(' ')[:-1]|join(' ') %}
|
||||
{% if not seo_description[-1] in ['.', '?', ':', '!'] %}
|
||||
{% set seo_more = seo_description + '…' %}
|
||||
{% set seo_description = seo_more|replace('"','') %}
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
<!-- Meta Article -->
|
||||
<meta name="author" content="{{ article.author }}"/>
|
||||
<meta name="description" content="{{ seo_description }}"/>
|
||||
<meta name="keywords" content="{{ article.tags|join(',')|escape }}"/>
|
||||
<meta property="article:section" content="{{ article.category }}"/>
|
||||
<meta property="video:release_date" content="{{ article.date.isoformat() }}"/>
|
||||
{% if article.modified %}
|
||||
<meta property="article:modified_time" content="{{ article.modified.isoformat() }}"/>
|
||||
{% endif %}
|
||||
<!-- Schema -->
|
||||
<meta itemprop="name" content="{{ article.title }}"/>
|
||||
<meta itemprop="description" content="{{ seo_description }}"/>
|
||||
<meta itemprop="uploadDate" content="{{ article.date.isoformat() }}"/>
|
||||
<meta itemprop="thumbnailURL" content="{{ SITEURL }}/{{ THEME_STATIC_DIR }}/../wp-content/uploads/article/poster/{{ article.image }}"/>
|
||||
<!-- OpenGraph -->
|
||||
<meta property="og:title" content="{{ article.title }}"/>
|
||||
<meta property="og:type" content="video.movie"/>
|
||||
<meta property="og:url" content="{{ SITEURL }}/{{ article.url }}"/>
|
||||
<meta property="og:description" content="{{ seo_description }}"/>
|
||||
<meta property="og:image" content="{{ SITEURL }}/{{ THEME_STATIC_DIR }}/../wp-content/uploads/article/poster/{{ article.image }}"/>
|
||||
{% for tag in article.tags %}
|
||||
<meta property="og:video:tag" content="{{ tag | escape }}"/>
|
||||
{% endfor %}
|
||||
{% if article.og_video %}
|
||||
<!-- videograph -->
|
||||
<meta property="og:video" content="{{ article.og_video }}"/>
|
||||
<meta property="og:video:secure_url" content="{{ article.og_video }}"/>
|
||||
<meta property="og:video:type" content="video/webm"/>
|
||||
<meta property="og:video:width" content="400"/>
|
||||
<meta property="og:video:height" content="300"/>
|
||||
<!-- /videograph -->
|
||||
{% endif %}
|
||||
<!-- Twitter -->
|
||||
<meta name="twitter:card" content="summary"/>
|
||||
<meta name="twitter:title" content="{{ article.title }} - {{ SITENAME }}"/>
|
||||
<meta name="twitter:description" content="{{ seo_description }}"/>
|
||||
<meta name="twitter:url" content="{{ SITEURL }}/{{ article.url }}"/>
|
||||
<meta name="twitter:image" content="{{ SITEURL }}/{{ THEME_STATIC_DIR }}/../wp-content/uploads/article/poster/{{ article.image }}"/>
|
||||
{% endblock %}
|
||||
{% endblock %}
|
||||
|
||||
{% block title %}{{ article.title|striptags }}{% endblock %}
|
||||
{% block menu_header %}{% endblock menu_header %}
|
||||
{% block menu_header %} <!-- empty -->{% endblock menu_header %}
|
||||
|
||||
{%- block content -%}
|
||||
<!-- Main -->
|
||||
|
||||
Reference in New Issue
Block a user