TL;DR: Modify the post-related templates in your active theme to add the following to the `````` element in each post:
```html
```
Also, make sure to define the ```zotero``` namespace prefix for this property in the ```prefix``` attribute on the `````` element. The proper value is ```http://www.zotero.org/namespaces/export# ```.
## Explanation and Example
The surest way I've found to make [the Firefox plugin for Zotero Standalone](https://www.zotero.org/download/) recognize my blog posts as blog posts (rather than just as generic web pages) is to insert a `````` element in the HTML `````` for each post. The `````` element must make use of a ```property``` attribute containing the name of the Zotero field we want to specify (in this case, ```itemType```). You won't find ```@property``` in the HTML5 specification; it's defined by RDFa. You also need a ```content``` attribute on the `````` element to carry the value Zotero expects, i.e., ```blogPost```. Thus:
```html
Zotero Item Keys (Again) | paregorios.org
```
## How to implement in Nikola
[The Nikola static site generator](https://getnikola.com), which I use for paregorios.org, uses a templating system to generate the HTML pages that are then deployed to the server (I author in Markdown; [Nikola supports a variety of authoring formats](https://getnikola.com/handbook.html#supported-input-formats)). So, I needed to modify the template(s) used for the individual HTML files that go in the "posts" section of the site so that they include the magic Zotero metadata described above. The Nikola Handbook, as currently written, makes it sound like you have to create your own custom theme (a collection of templates and [CSS](https://en.wikipedia.org/wiki/Cascading_Style_Sheets) files) if you want to modify template behavior, but that it is not the case. You can selectively override templates from whatever stock or third-party theme you have installed and configured.
I use [the "bootstrap4" theme that ships with Nikola 8](https://github.com/getnikola/nikola/tree/master/nikola/data/themes/bootstrap4), rather than the default "bootblog4" (one changes this via the ```THEME``` variable in ```conf.py```), so I went poking around in the code to find out how and where the ``````, ``````, and `````` elements get generated. I discovered that -- in the boostrap4 theme -- there are three templates involved: ```post.tmpl```, ```post_helper.tmpl```, and ```base_helper.tmpl```. Nikola makes it easy to get copies of those templates for the purpose of overriding. I entered the following commands and the command line:
```bash
nikola theme -c post.tmpl
nikola theme -c post_helper.tmpl
nikola theme -c base.tmpl
```
Nikola created a ```templates``` subdirectory for me and copied the three files into it. Any changes I make in those copies are reflected in output the next time I run ```nikola build```.
To get the behavior I wanted I had to do the following:
1. Modify ```templates/base_helper.tmpl``` to define the ```zotero``` namespace prefix,
2. Modify ```templates/post_helper.tmpl``` to write the Zotero-related `````` element I want, and
3. Modify ```templates/post.tmpl``` to invoke the code I added to ```templates/post_helper.tmpl```.
[Select this link for a diff via github that shows you what I changed](https://github.com/paregorios/paregorios.2018/commit/3c6fd3798fd16d9a550388a93729854d51cfa7fa#diff-0ce77a451d321cc843e940a5a57847ce).
## A Note on the Zotero Namespace
Exceptionally devoted readers may recall that [my last post on this subject](../../04/what-zotero-wants) prophesied the use of [the PRISM namespace](https://www.idealliance.org/prism-metadata) to achieve Nikola+Zotero harmony. In fact, I tried adding `````` based on [what I was seeing in the Zotero translator code](https://github.com/zotero/translators/blob/beb41ffeb07290e8937a0b99d313a868783487ab/RDF.js#L617), but got no joy (i.e., Zotero was still identifying my blog posts as generic web pages). I had two options: either try to troubleshoot the relatively complex logic used in the Zotero translator to find out what I was doing wrong or why some other value was getting prioritized over my PRISM metadata, or take a cue from [the big assignment in the Zotero translator code that prioritizes a Zotero item type over any other metadata scheme](https://github.com/zotero/translators/blob/beb41ffeb07290e8937a0b99d313a868783487ab/RDF.js#L684). Embracing laziness as a virtue -- and also noticing that in newer versions of PRISM "blogEntry" seems to have been moved from the Genre vocabulary where the Zotero translator expects it to [the Content Type vocabulary](http://www.prismstandard.org/vocabularies/3.0/contenttype.xml) -- I went with the latter option, got the result I was looking for, committed the changes, redeployed, wrote this blog post, and moved on to other things.