Skip to content
Markdown API · Use case

Convert a URL to Markdown with metadata frontmatter

URL to Markdown with metadata means every converted page arrives with its title, author and date attached, not just its text. A Markdown body without them is hard to index and harder to cite, which hurts RAG loaders, static site importers, note apps and research archives alike. The Markdown API can prepend the page’s normalized metadata as YAML frontmatter, so each document describes itself.

The problem

Markdown without metadata is hard to index and cite

Pipelines that feed LLMs, search indexes or knowledge bases need more than the text: who wrote it, when, what it is about, how long it is. Without those fields a retrieved chunk cannot be attributed, sorted by date or filtered by language, and the answer built on it cannot cite its source.

Scraping those fields separately means a second request and a second parser. Open Graph, Twitter Cards, JSON-LD and plain HTML tags disagree with each other and vary per site, so the metadata code grows a special case for every source. Then the two results have to be joined, and they may not even describe the same version of the page.

Set meta to true on a Markdown request served with embed and Microlink prepends a YAML frontmatter block: title, author, date, publisher, language, description and canonical URL, the image and logo with their dimensions, plus word count and reading time. The Markdown body follows, from the same fetch.

How it works

How to get Markdown with YAML frontmatter from a URL

The direct Markdown response carries the frontmatter. In the SDK, the same fields ride along as JSON next to the Markdown rule through the metadata method.

1 · Direct Markdown with frontmatter
curl 'https://api.microlink.io/?url=https%3A%2F%2Fexample.com%2Fblog%2Fpost&data.markdown.attr=markdown&meta=true&embed=markdown'

The response body is text/markdown: a YAML block between two --- lines with keys such as title, author, date, word_count and reading_time, then the converted page. Save it as a .md file and any frontmatter-aware loader can read it.

2 · Metadata and Markdown as JSON
import createClient from 'microlink.io'

const microlink = createClient({
  apiKey: process.env.MICROLINK_API_KEY
})

const { title, author, date, markdown } = await microlink.metadata(
  'https://example.com/blog/post',
  { data: { markdown: { attr: 'markdown' } } }
)

metadata() returns the normalized fields, and the markdown rule adds the body to the same object. One request, one cache entry, no YAML to parse.

3 · Build your own frontmatter
import createClient from 'microlink.io'

const microlink = createClient({
  apiKey: process.env.MICROLINK_API_KEY
})

const page = await microlink.metadata('https://example.com/blog/post', {
  data: { markdown: { attr: 'markdown' } }
})

const document = [
  '---',
  `title: ${JSON.stringify(page.title)}`,
  `author: ${JSON.stringify(page.author)}`,
  `date: ${page.date}`,
  `source: ${page.url}`,
  '---',
  '',
  page.markdown
].join('\n')

When you want a custom field set, different key names or extra fields such as a collection id, compose the frontmatter yourself from the JSON response.

Parameters used
  • meta true detects the normalized fields. With embed=markdown they become the YAML frontmatter. Default true.
  • data The Markdown rule: data.markdown.attr=markdown serializes the page as Markdown.
  • embed Return the Markdown field as the response body with a text/markdown content type.
  • prerender true forces a browser render for client-side pages whose metadata only exists after JavaScript runs. Default auto.

Fields that cannot be detected come back as null in JSON, so consumers should treat every field as optional. The data fields reference documents each normalized field and how it is resolved.

Why it works

Why YAML frontmatter is the right container for page metadata

Frontmatter is the convention that static site generators, note apps and RAG loaders already understand, so the metadata travels inside the file instead of in a sidecar.

01 · Normalized fields
The same keys for every site.
Microlink merges Open Graph, Twitter Cards, JSON-LD and the HTML itself into one predictable shape. Your loader reads title, author and date the same way for a newspaper and a personal blog.

The choosing fields guide shows how to request only the keys you index when you work with the JSON response, and the Metadata API page covers the normalization itself.

02 · Sized for context windows
Word count and reading time tell you what you are ingesting.
The frontmatter includes word_count and reading_time, so a pipeline can chunk, skip or prioritize documents before spending tokens on them. A 200-word stub and a 9,000-word guide no longer look the same in the queue.

Pair it with clean Markdown scoped to the content when navigation and footers would otherwise pad the body.

03 · One request
Metadata and content from the same fetch.
Because both come from one request, the frontmatter describes exactly the body below it: same URL, same moment, same cache entry. A cache hit returns both and does not count against your quota.

When not to: if you only need the body for a summarizer, keep meta at false. Skipping metadata detection is the first speedup the performance guide recommends for content-only requests.

FAQ

Which fields appear in the Markdown frontmatter?

The normalized metadata: title, author, date, publisher, lang, description and url, the image and logo with their type, size and dimensions, plus word_count and reading_time. Fields the page does not expose are left out or empty, so treat every key as optional.

How do I convert a URL to Markdown with metadata in one request?

Send data.markdown.attr=markdown with meta=true and embed=markdown. The response is a Markdown file that starts with a YAML frontmatter block and continues with the converted page. Without embed, the same fields and the Markdown arrive together as JSON.

Can I get the Markdown frontmatter fields as JSON instead of YAML?

Yes. Call metadata() with a data.markdown rule and you get the same fields as JSON next to the Markdown body, then compose the frontmatter however you like. The same pattern extends to your own rules, as in custom fields alongside the metadata.

Does Markdown frontmatter work for PDFs and office documents?

The Markdown conversion works for PDF, DOCX, XLSX and PPTX URLs, as described in PDF and office documents to Markdown. The metadata fields depend on what the file exposes, so expect fewer of them than for a web page.

Can I choose which fields go into the Markdown frontmatter?

The frontmatter of the direct response carries the full normalized set. For a custom selection, request the JSON response, pick the fields you need and write the YAML block yourself, as the third step above shows. It is a few lines of code and you control the key names.
Related use cases

Solve the next problem with the same API

Clean Markdown, no boilerplate

Convert only the article body: one selector keeps navigation, ads and widgets out of the Markdown.

PDF and office documents to Markdown

Convert PDF, DOCX, XLSX and PPTX URLs to readable Markdown with the same request you use for web pages.

LLM context from any URL

Compose Markdown, links, emails, metadata and tech stack from one URL into a context object for your agent.

Bulk Markdown conversion with caching

Convert thousands of URLs in parallel, cached per URL and refreshed in the background for cheap re-indexing.

Custom fields alongside metadata

Get prices, ratings, headings or any CSS selector, typed and returned next to the normalized metadata.

Only the fields you need

Include or exclude normalized fields per request and trim the JSON for faster, lighter metadata calls.

Ready for self-describing Markdown?

Title, author, date and reading time on top of every converted page. Start on the free tier and feed your pipeline documents that explain themselves.