13

I want to insert some metadata (i.e. keywords, description, author) inside my web pages created by Sphinx.

I found

:fieldname: Field content

in the documentation of Sphinx, but I have no idea how to use it.

bad_coder
  • 11,289
  • 20
  • 44
  • 72
xxks-kkk
  • 2,336
  • 3
  • 28
  • 48
  • I already figure out. There is a directive called "meta", which perfectly meets my desire. You can find it here: http://docutils.sourceforge.net/docs/ref/rst/directives.html#meta – xxks-kkk Jan 10 '13 at 08:05

1 Answers1

12

I already figure out. There is a directive called "meta", which perfectly meets my desire.

You can find it here: http://docutils.sourceforge.net/docs/ref/rst/directives.html#meta

xxks-kkk
  • 2,336
  • 3
  • 28
  • 48
  • Where did you insert the meta directive? I've tried inserting it both above and below the page header, but the Sphinx HTML output does not translate the directive into HTML meta tags. e.g.: .. meta:: :description: Useful topic :keywords: plaintext, markup language ******************************************************************************** Page title ******************************************************************************** .. meta:: :description: Useful topic :keywords: plaintext, markup language – Mark May 21 '18 at 11:51
  • @Mark I inserted `meta` below the title of the page: https://raw.githubusercontent.com/xxks-kkk/old_web/120890ca33938cee7a17eaa65e7f3df3dd54b1bc/web2/index.rst However, I haven't used `meta` a lot since 2012. If the above example doesn't work, you can try to hack the jinja template and directly add meta information into your template. Hope this helps. – xxks-kkk May 22 '18 at 03:44
  • Thanks @zack! Further research reveals someone on our team removed the {{ metatags }} variable from our layout.html file sometime in the past. Restoring it restored support for the .. meta directive. – Mark May 23 '18 at 13:56
  • @Mark Glad to hear that :) – xxks-kkk May 23 '18 at 15:00