How can I add header metadata without adding the <h1>?
Asked Answered
I

1

6

I'm writing something in markdown and converting it to html with pandoc, but when I add the title variable in the yaml header, it also adds an <h1> to the top of the document, which I don't want. In the pandoc documentation it says to use the title-meta variable, but it still says

[WARNING] This document format requires a nonempty <title> element.

Is there a way to set the title without adding the title block?

command I'm using:

pandoc -s "file.md" -o "file.html"`

output of pandoc --version:

pandoc 2.10.1
Compiled with pandoc-types 1.21, texmath 0.12.0.2, skylighting 0.8.5
Default user data directory: C:\Users\noah\AppData\Roaming\pandoc
Copyright (C) 2006-2020 John MacFarlane
Web:  https://pandoc.org
This is free software; see the source for copying conditions.
There is no warranty, not even for merchantability or fitness
for a particular purpose.
Insure answered 16/9, 2020 at 21:20 Comment(1)
Weird, right? Converting from Markdown, I almost always have a top-level # Headline, so adding an extraneous <h1> is not something I would want Pandoc to do for me. Maybe there are some formats where that makes more sense…Celom
M
6

One can set an explicit title with --metadata=title="My title" while simultaneously preventing the output of the <h1> and <header> elements by setting the template variable title to an empty string:

pandoc --metadata=title="Fancy title" --variable=title="" ... 
Monkish answered 17/9, 2020 at 7:17 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.