Getting Started with the Htmlhost CLI
Why use a CLI for hosting?
You already have a code editor and a terminal open. Your HTML files live in a project folder. So why should you have to open a browser, find a hosting dashboard, and drag files around just to get a URL?
The htmlhost CLI lets you publish straight from your terminal. One command, and your project is live. No context-switching, no extra tabs, no upload forms.
Installing the CLI
The CLI is a single npm package with zero dependencies. If you have Node.js 18 or later, you're all set.
npm i -g htmlhost-cli
After installation, the htmlhost command is available globally in your terminal.
Authenticating
Before you can deploy, you need an API token. Here's how to get one:
- Go to htmlhost.co/settings (sign in if you haven't)
- Under "API Keys," click Create Key
- Copy the generated token
Then run:
htmlhost login
Paste your token when prompted. The CLI saves it to ~/.htmlhostrc and you won't need to log in again on this machine.
Your first deploy
Navigate to a folder that contains an index.html file and run:
htmlhost deploy
That's it. The CLI reads every file in the folder, uploads them, and gives you a live URL like https://bold-fern-x3k.htmlhost.co.
You'll see a summary of all the files being deployed, and a confirmation prompt before anything goes live. Every HTML file becomes a page, and all your CSS, JavaScript, images, and fonts come along for the ride.
Re-deploying
When you make changes and run htmlhost deploy again, the CLI remembers your site. It doesn't create a new URL each time. Instead, it updates the existing site in place. Your URL stays the same, but the content is fresh.
This is possible because the CLI stores a small .htmlhost file in your project folder. That file links your local project to the remote site. You never have to manage slugs or remember URLs.
Deploying a single file
If you only have one HTML file and don't want to deploy a whole directory, just point to it:
htmlhost deploy page.html
The CLI will detect any local CSS, JavaScript, or images referenced in your HTML, upload them automatically, and rewrite the references to hosted URLs. Your single-file project becomes a fully self-contained page.
What happens behind the scenes
When you deploy, the CLI:
- Scans your folder for files (skipping
node_modules,.git, and other junk) - Maps HTML files to clean URL paths (
about.htmlbecomes/about) - Uploads assets with content-based hashing, so unchanged files are skipped
- Gives your site HTTPS and CDN delivery automatically
There's no build step and no configuration file. The folder you deploy is the site you get.
Useful options
| Option | What it does |
|---|---|
--ttl 30d | Set how long the site stays live (1d, 7d, 30d, or never) |
--title "My Site" | Give the site a title visible on your dashboard |
--new | Force a brand-new site instead of updating the linked one |
--json | Output the result as JSON (useful for CI/CD scripts) |
Next steps
Once you're comfortable deploying, there's more you can do from the CLI. You can pull remote changes that were made through the web editor, clone an existing site into a local folder, or let the CLI automatically detect conflicts before you overwrite someone else's work.
Start with npm i -g htmlhost-cli and see how fast your next project goes live.
Ready to try it yourself?
Paste HTML, get a link. Deploy your site in under 3 seconds — no config, no build step.
Start hosting