Add a Table of Contents and Page Numbers to a Markdown PDF
Generate a clickable table of contents from your headings and add “Page X of Y” headers and footers when converting Markdown to PDF — no LaTeX needed.
Updated · 5 min read
A table of contents and page numbers turn a long Markdown export into a document people can navigate. Here’s how to add both — and a cover page — without leaving the browser.
Generate a table of contents
There are two ways in the editor:
- Anywhere you like: type
[toc](or[[toc]]) on its own line. The contents list appears exactly there. - At the top automatically: open Style → Document and turn on Table of contents. Choose the depth — H1 only, up to H2, H3 or H4.
Every entry links to its heading, and those links keep working in the PDF. Headings get stable IDs from their text, so ## Getting started links to #getting-started.
Tip: turn on Numbered headings to prefix H2–H4 with 1., 1.1 and 1.1.1 — handy for reports and specifications.
Add page numbers, headers and footers
Open Style → Header & footer and switch it on. You get three slots at the top and three at the bottom (left, centre, right). Type any text and use these tokens:
| Token | Becomes |
|---|---|
{page} |
Current page number |
{pages} |
Total number of pages |
{title} |
Document title (front matter title: or the name box) |
{author} |
Front matter author: |
{date} |
Front matter date:, or today |
A classic setup is {title} in the header’s left slot and Page {page} of {pages} in the footer’s right slot.
These headers use the CSS page-margin boxes that Chrome and Edge support. In Firefox and Safari, tick the browser’s own “Headers and footers” option in the print dialog to get page numbers.
Add a cover page
Put a front matter block at the very top of your document:
---
title: Quarterly Report
subtitle: Q3 2026 results and outlook
author: Finance Team
date: 2026-10-02
---
Then turn on Style → Document → Cover page. The cover uses your title, subtitle, author and date, and headers and footers are hidden on it automatically.
Save settings with the document
Any setting can live in the front matter too, so the document carries its own layout wherever it goes:
---
title: Handbook
pdf:
theme: academic
toc: true
headerFooter: true
footer: { right: "Page {page} of {pages}" }
---
Try it on your own document
Free, private and right in your browser — no signup.