Let’s say we have input.md
file:
# Name
Contents
— and we need to automatically rewrite it in HTML:
# pandoc --from markdown --to html input.md -o output.html
# cat ./output.html
<h1 id="name">Name</h1>
<p>Contents</p>
Now, we want Pandoc to prepend something like <head><title>Custom title</title></head>
to output.html
.
How to accomplish this?
The following approaches failed:
# pandoc --from markdown --to html --metadata title="Custom title" input.md -o output.html
# echo '{title: "Custom title"}' > metadata.json
# pandoc --from markdown --to html --metadata-file=metadata.json input.md -o output.html
Also, I am aware of --title
command line option: it indeed creates <title>
in my case, but writes Custom title – input
there, and also adds a lot of styles (although the latter is not an issue itself).
2
Answers
Finally, a command line snippet solving my issue follows (great thanks to @mb21 for the answer and the comment above):
You’re missing the
-s
or--standalone
option:Or instead of the
--metadata
flag just do: