Skip to content

Commit

Permalink
(feat): SEO: Add frontpage meta keywords tags based on all articles
Browse files Browse the repository at this point in the history
Signed-off-by: Pablo Iranzo Gómez <Pablo.Iranzo@gmail.com>
  • Loading branch information
iranzo committed Jan 22, 2020
1 parent 49c3b57 commit 7d6dba6
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 16 deletions.
1 change: 1 addition & 0 deletions THANKS.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ Thanks goes to these wonderful people ([emoji key](https://allcontributors.org/d

<!-- markdownlint-enable -->
<!-- prettier-ignore-end -->

<!-- ALL-CONTRIBUTORS-LIST:END -->

This project follows the [all-contributors](https://github.com/all-contributors/all-contributors) specification. Contributions of any kind welcome!
Expand Down
6 changes: 3 additions & 3 deletions templates/_includes/smo_metadata.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{% macro smo_metadata(article) %}
{% if article %}
<meta property="og:title" content="{{ article.title|striptags|e }} {%if article.subtitle %} - {{ article.subtitle|striptags|e }} {% endif %}"/>
<meta property="og:url" content="{{ SITEURL }}/{{ article.url }}" />
<meta property="og:description" content="{{article.summary|striptags|e}}" />
Expand All @@ -12,7 +12,8 @@
{% endif %}
<meta name="twitter:title" content="{{ article.title|striptags|e }} {%if article.subtitle %} - {{ article.subtitle|striptags|e }} {% endif %}">
<meta name="twitter:description" content="{{article.summary|striptags|e}}">
{% if article.featured_image %}
{% endif %}
{% if article and article.featured_image %}
<meta property="og:image" content="{{article.featured_image}}" />
<meta name="twitter:image" content="{{article.featured_image}}" >
{% else %}
Expand All @@ -22,4 +23,3 @@
<meta name="twitter:image" content="{{FEATURED_IMAGE}}" >
{% endif %}
{% endif %}
{% endmacro %}
3 changes: 0 additions & 3 deletions templates/article.html
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,6 @@
{% if article.tags or article.category or article.keywords %}
<meta name="keywords" content="{{ [article.tags|join(', '), article.category, article.keywords]|join(', ') }}" />
{% endif %}

{% from '_includes/smo_metadata.html' import smo_metadata with context %}
{{ smo_metadata(article) }}
{% endblock meta_tags_in_head %}

{% block head_links %}
Expand Down
3 changes: 3 additions & 0 deletions templates/base.html
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,12 @@
<meta name="author" content="{{ AUTHOR }}" />
{% endif %}

{% include '_includes/smo_metadata.html' with context %}

{% from '_includes/_defaults.html' import SITE_DESCRIPTION with context %}
{% if SITE_DESCRIPTION %}
<meta name="description" content="{% block head_description %}{{ SITE_DESCRIPTION|e }}{% endblock head_description %}" />
<meta name="twitter:description" content="{{SITE_DESCRIPTION|e}}">
{% endif %}
{% block meta_tags_in_head %}
{% from '_includes/_defaults.html' import TWITTER_USERNAME with context %}
Expand Down
13 changes: 3 additions & 10 deletions templates/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -15,18 +15,11 @@
<meta name="twitter:title" content="{{ SITENAME|striptags|e }}">
{% endif %}
<meta property="og:url" content="{{ SITEURL }}" />
{% from '_includes/_defaults.html' import SITE_DESCRIPTION with context %}
{% if SITE_DESCRIPTION %}
<meta property="og:description" content="{{SITE_DESCRIPTION|e}}" />
<meta name="twitter:description" content="{{SITE_DESCRIPTION|e}}">
{% endif %}
<meta property="og:site_name" content="{{ SITENAME|striptags|e }}" />
<meta property="og:article:author" content="{{ AUTHOR }}" />
{% from '_includes/_defaults.html' import FEATURED_IMAGE with context %}
{% if FEATURED_IMAGE %}
<meta property="og:image" content="{{FEATURED_IMAGE}}" />
<meta name="twitter:image" content="{{FEATURED_IMAGE}}" >
{% endif %}
<!-- Fill in Site Keywords-->
<meta name="keywords" content="{% for tag, _ in tags|sort %} {{ tag }}, {% endfor %}{% for category in categories|sort %} {{ category }}, {% endfor %}" />

{% endblock meta_tags_in_head %}

{% block content %}
Expand Down

0 comments on commit 7d6dba6

Please sign in to comment.