Why is the Date Missing in Your Pandoc PDF?

When converting Markdown files to PDF using Pandoc, you might expect your YAML front matter metadata—like the date—to automatically appear at the top of your document. However, it's common to run into a frustrating issue where the date simply refuses to render, even when your YAML syntax is perfectly valid.

If your date displays correctly on a small test file but disappears in your main document, the issue usually boils down to a few specific quirks in how Pandoc and its underlying LaTeX engine handle templates. Here is how to fix it.

1. The Most Common Culprit: A Missing "Title" Field

By default, Pandoc uses LaTeX to generate PDFs. In LaTeX, the date and author are part of the title block, which is rendered using the \maketitle command.

In Pandoc's default LaTeX template, if there is no "title" variable defined, the entire title block (including the date and author) is skipped entirely.

If your YAML looks like this:

---
date: June 14, 2026
linestretch: 1.5
---

The date will not render. To fix this, simply add a title field to your YAML block:

---
title: "My Document Title"
date: June 14, 2026
linestretch: 1.5
---

2. The YAML Block is Not at the Absolute Beginning

For Pandoc to parse YAML front matter correctly, the opening triple-dash (---) must be the very first line of your Markdown file.

  • Ensure there are no blank lines above the first ---.
  • Ensure there are no spaces or hidden characters (like a Byte Order Mark / BOM) preceding the dashes.

If your 4,000-word document has even a single space or empty line before the YAML block, Pandoc will treat the entire block as standard Markdown text, ignoring your metadata variables.

3. Always Use the Standalone Flag

While compiling directly to a PDF format (-o document.pdf) usually forces Pandoc into standalone mode, it is best practice to explicitly use the -s or --standalone flag. This tells Pandoc to search for and apply the document template that processes YAML variables:

pandoc j.md -s -o jtest.pdf

4. Check for Hidden Markdown Syntax Errors

In large documents, it is easy to accidentally break the YAML parser. Check for the following:

  • Unescaped Colons: If your title or date contains a colon (e.g., title: My Book: A Memoir), it will break the YAML parser. Wrap the value in double quotes: title: "My Book: A Memoir".
  • Duplicate YAML blocks: Ensure you don't have multiple --- metadata blocks scattered throughout your document, which can confuse the parser.

Summary Checklist

If your date is still not showing up, run through this quick checklist:

  1. Does your YAML front matter include a title:?
  2. Is the YAML block at the absolute top (line 1) of your file?
  3. Are you compiling using the -s flag?