Skip to content

CLI Guide

The MDtoLink CLI lets you publish, update, and manage markdown documents directly from your terminal.

Install globally via your preferred package manager:

Terminal window
# npm
npm install -g mdtolink
# pnpm
pnpm add -g mdtolink
# bun
bun add -g mdtolink

This gives you two commands: mdtolink and mdtl (shorthand). Both work identically — use whichever you prefer.

The CLI supports short aliases for every command, and mdtl <file> works as a shorthand for mdtl publish <file>:

Terminal window
# These are all equivalent:
mdtolink publish notes.md
mdtl publish notes.md
mdtl p notes.md
mdtl notes.md

All available aliases:

CommandAliases
publishp, pub
unpublishrm, remove, delete
listls, l
loginauth, signin
logoutsignout

Before publishing, authenticate with your MDtoLink account:

Terminal window
mdtolink login

This opens your browser where you authorize the CLI. Once approved, your session token is stored locally at ~/.config/mdtolink/token.json.

You don’t need to login before running publish — if you’re not authenticated, the CLI will prompt you to authorize inline.

Terminal window
mdtolink publish README.md
# → Published: https://mdtolink.com/d/xk9f2m

The CLI reads the file, uploads it to your account, and returns a shareable URL.

By default, the title is derived from the filename. Override it with --title:

Terminal window
mdtolink publish notes.md --title "Meeting Notes - March 2026"

Pro users can set custom filenames:

Terminal window
mdtolink publish notes.md --slug my-notes
# → Published: https://mdtolink.com/d/my-notes

Pro users can publish documents that are only visible to them when signed in. Anyone else sees “Document not found.”

Terminal window
mdtolink publish notes.md --private
# → Published (private): https://mdtolink.com/@david/notes
# --draft is an alias for --private
mdtolink publish notes.md --draft

Publishing the same file again updates the existing document — same URL, fresh content:

Terminal window
# First publish
mdtolink publish notes.md
# → Published: https://mdtolink.com/d/xk9f2m
# Edit notes.md, then:
mdtolink publish notes.md
# → Updated: https://mdtolink.com/d/xk9f2m

This works because the CLI stores a local mapping between file paths and document IDs in ~/.config/mdtolink/documents.json.

View all your published documents:

Terminal window
mdtolink list

Paginate with --limit and --offset:

Terminal window
mdtolink list --limit 10 --offset 20

Remove a document by file path or slug:

Terminal window
# By file path
mdtolink unpublish notes.md
# By slug
mdtolink unpublish my-notes

Or run without arguments for an interactive picker:

Terminal window
mdtolink unpublish
# Shows your recent documents with checkbox selection

Clear your stored authentication token:

Terminal window
mdtolink logout
VariableDefaultDescription
MDTOLINK_SERVER_URLhttps://api.mdtolink.comAPI server URL
MDTOLINK_APP_URLhttps://mdtolink.comBase URL for document links