Metadata
Assigns additional description and images to categories, authors and tags in Pelican-powered sites. As it extends a Pelican-specific feature, it has no equivalent for other themes.
How to use
Download the m/metadata.py file, put it including
the m/ directory into one of your PLUGIN_PATHS and add m.metadata
package to your PLUGINS in pelicanconf.py. In order to have the
contents properly rendered, it’s advised to add the new fields to
FORMATTED_FIELDS:
PLUGINS += ['m.metadata'] FORMATTED_FIELDS += ['description', 'badge']
This plugin parses additional info from pages in subdirectories of the contents
directory (i.e., where the PATH setting points to). By default, the
directories are as follows and can be configured with these settings:
M_METADATA_AUTHOR_PATH = 'authors' M_METADATA_CATEGORY_PATH = 'categories' M_METADATA_TAG_PATH = 'tags'
The m.css Pelican theme recognizes presence of this plugin and renders the
additional metadata both in the page and in the Open Graph
and Twitter Card
social <meta> tags, in addition to tags rendered by
articles themselves.
See below for more information.
Category metadata
Category pages are matched to categories based on the slug (so e.g. metadata
for category named Guest posts will be in a file named
categories/guest-posts.rst). The following metadata are recognized:
- Page content is exposed to the theme in
category.page.contenton the category page and used to fill category details block on top of the category page in the m.css Pelican theme. If not set, no category details block is rendered. - Page title is exposed to the theme in
category.page.titleon the category page and inarticle.category.badge_titlein all articles being in given category. In the m.css Pelican theme it is used as caption in category details block, inog:title/twitter:titlesocial<meta>tag on category page and as badge title on article pages. Can be used to provide a longer version of category name for article badge and detailed category info. If not set, the m.css Pelican theme uses the global category name (the one set by articles) instead — but note that since 3.8, Pelican will warn about this and suggest to specify the title explicitly. - The
:description:field is exposed to the theme incategory.page.descriptionon the category page. The m.css Pelican theme uses it in<meta name="description">. If not set, no tag is rendered. - The
:summary:field is exposed to the theme incategory.page.summaryon the category page. The m.css Pelican theme uses it inog:description/twitter:descriptionsocial<meta>tag. If not set, no tag is rendered. - The
:badge:field is exposed to the theme inarticle.category.badgein all articles being in given category. The m.css Pelican theme uses it to display an informational badge at the end of article pages. Similarly to page content, it’s possible to use advanced reST formatting capabilities here. If not set, no badge at the end of articles in given category is rendered. - The
:image:field is exposed to the theme incategory.page.imageon the category page and inarticle.category.imagein all articles being in given category. The m.css Pelican theme uses it to add an image to category badges on articles, to category details on category page and inog:image/twitter:imagesocial<meta>tags on category page. If article cover image is not specified, the image is used also forog:image/twitter:imageon given article, overriding the globalM_SOCIAL_IMAGE. It’s expected to be smaller and square similarly to theM_SOCIAL_IMAGEdescribed in the theme documentation. If not set, the details and badges are rendered without images and no social tag is present. Does not affecttwitter:card, it’s set tosummaryorsummary_large_imagedepending only on presence of article cover image.
Example of a completely filled category page, saved under categories/guest-posts.rst
and matching a category named Guest posts:
Posts by our users ################## :image: {static}/categories/guest-posts.jpg :description: User stories and product reviews :summary: Stories of our users and honest reviews of our product. :badge: This article is a guest post. Want to share your story as well? Head over to the `intro article <{filename}/blog/introducing-guest-posts.rst>`_ to get to know more. We'll happily publish it here. This section contains guest posts, reviews and success stories. Want to share your story as well? Head over to the `intro article <{filename}/blog/introducing-guest-posts.rst>`_ to get to know more. We'll happily publish it here.
Tag metadata
Tag pages are matched to authors based on the slug (so e.g. metadata for
tag named Pantomime will be in a file named tags/pantomime.rst). The
following metadata are recognized:
- Page content is exposed to the theme in
tag.page.contenton the tag page and used to fill tag details block on top of the tag page in the m.css Pelican theme. If not set, no tag details block is rendered. - Page title is exposed to the theme in
tag.page.titleon the tag page, is used as caption in tag details block on tag page and inog:title/twitter:titlesocial<meta>tag. Can be used to provide a longer version of tag name on this page. If not set, the m.css Pelican theme uses the global tag name (the one set by articles) instead — but note that since 3.8, Pelican will warn about this and suggest to specify the title explicitly. - The
:description:field is exposed to the theme intag.page.descriptionon the tag page. The m.css Pelican theme uses it in<meta name="description">. If not set, no<meta>tag is rendered. - The
:summary:field is exposed to the theme intag.page.summaryon the tag page. The m.css Pelican theme uses it inog:description/twitter:descriptionsocial<meta>tag. If not set, no<meta>tag is rendered.
Example of a completely filled tag page, saved under tags/pantomime.rst
and matching a tag named Pantomime:
¯\_(ツ)_/¯ ########## :description: ¯\_(ツ)_/¯ :summary: ¯\_(ツ)_/¯ ¯\_(ツ)_/¯