Added support for meta keywords

This commit is contained in:
squidfunk 2020-11-05 21:10:58 +01:00
parent 6608f3a439
commit 72494f08bb
3 changed files with 12 additions and 8 deletions

View File

@ -13,6 +13,11 @@
{% elif config.site_description %} {% elif config.site_description %}
<meta name="description" content="{{ config.site_description }}"> <meta name="description" content="{{ config.site_description }}">
{% endif %} {% endif %}
{% if page and page.meta and page.meta.keywords %}
<meta name="keywords" content="{{ page.meta.keywords }}">
{% elif config.site_keywords %}
<meta name="keywords" content="{{ config.site_keywords }}">
{% endif %}
{% if page.canonical_url %} {% if page.canonical_url %}
<link rel="canonical" href="{{ page.canonical_url }}"> <link rel="canonical" href="{{ page.canonical_url }}">
{% endif %} {% endif %}

View File

@ -22,7 +22,6 @@
site_name: Material for MkDocs site_name: Material for MkDocs
site_url: https://squidfunk.github.io/mkdocs-material/ site_url: https://squidfunk.github.io/mkdocs-material/
site_author: Martin Donath site_author: Martin Donath
site_keywords: Material,MkDocs
site_description: >- site_description: >-
Create a branded static site from a set of Markdown files to host the Create a branded static site from a set of Markdown files to host the
documentation of your Open Source or commercial project customizable, documentation of your Open Source or commercial project customizable,

View File

@ -31,13 +31,6 @@
<meta charset="utf-8" /> <meta charset="utf-8" />
<meta name="viewport" content="width=device-width,initial-scale=1" /> <meta name="viewport" content="width=device-width,initial-scale=1" />
<!-- Page keywords -->
{% if page and page.meta and page.meta.keywords %}
<meta name="keywords" content="{{ page.meta.keywords }}" />
{% elif config.site_keywords %}
<meta name="keywords" content="{{ config.site_keywords }}" />
{% endif %}
<!-- Page description --> <!-- Page description -->
{% if page and page.meta and page.meta.description %} {% if page and page.meta and page.meta.description %}
<meta name="description" content="{{ page.meta.description }}" /> <meta name="description" content="{{ page.meta.description }}" />
@ -45,6 +38,13 @@
<meta name="description" content="{{ config.site_description }}" /> <meta name="description" content="{{ config.site_description }}" />
{% endif %} {% endif %}
<!-- Page keywords -->
{% if page and page.meta and page.meta.keywords %}
<meta name="keywords" content="{{ page.meta.keywords }}" />
{% elif config.site_keywords %}
<meta name="keywords" content="{{ config.site_keywords }}" />
{% endif %}
<!-- Canonical --> <!-- Canonical -->
{% if page.canonical_url %} {% if page.canonical_url %}
<link rel="canonical" href="{{ page.canonical_url }}" /> <link rel="canonical" href="{{ page.canonical_url }}" />