Back to Blog

How to share an HTML file as a link: rendered, with its CSS and images

Put the HTML file in a folder as index.html with its CSS and images, then publish the folder to get a link that renders instead of downloading.

CLI 0.5.0Tested

To share an HTML file as a link that opens as a page, name it index.html and publish its folder with npx -y @instahost/cli publish ./site --ttl 1h --json. The returned URL opens the page and loads its CSS and images. Uploading the HTML file with share gives visitors a download.

Start in an empty directory with Bash, Node.js 20 or later, curl and jq. Use the same shell throughout and leave INSTAHOST_API_KEY unset. If you've linked this environment with npx -y @instahost/cli link, your uploads go to your account and their receipts have no delete or claim token. Run npx -y @instahost/cli whoami --json first; it should report anonymous. The examples create two anonymous links with a one-hour lifetime. Keep the JSON receipts private. Their delete and claim tokens are redacted below. The CLI prints each JSON document on one line. The examples use jq . for readability.

Make a test page with a stylesheet and an image

The page loads style.css and img/logo.svg by relative URL. Its copy, page.html, is the single file shared next.

umask 077
mkdir -p site/img
cat > site/index.html <<'EOF'
<!doctype html>
<html lang="en">
<head><meta charset="utf-8"><title>Report</title><link rel="stylesheet" href="style.css"></head>
<body><h1>Hello from a folder</h1><img src="img/logo.svg" alt="Logo" width="40" height="40"></body>
</html>
EOF
printf 'h1 { font-family: sans-serif; color: #2b6cb0; }\n' > site/style.css
printf '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 40 40"><circle cx="20" cy="20" r="18" fill="#2b6cb0"/></svg>\n' > site/img/logo.svg
cp site/index.html page.html

What happens when you share the .html file on its own

share uploads one file to the files host:

npx -y @instahost/cli share ./page.html --ttl 1h --json > share.json

share.json holds the result. Give visitors the url. To add the upload to your Console account, open the private claim_url before the file expires, sign in with a verified email and select Claim artifact in the same tab. The claim link works once.

{
  "ok": true,
  "id": "7k77gh2pp33soj54kwfktm2r6b",
  "type": "file",
  "access": "unlisted",
  "url": "https://files.instahost.cloud/7k77gh2pp33soj54kwfktm2r6b/page.html",
  "expires_at": "2026-12-03T12:04:41Z",
  "delete_token": "ihd_[redacted]",
  "access_token": null,
  "access_url": null,
  "claim_url": "https://console.instahost.dev/claim/7k77gh2pp33soj54kwfktm2r6b#ihc_[redacted]",
  "file_count": 1,
  "total_bytes": 238,
  "skipped": [],
  "warnings": []
}

The headers decide what a browser does with that URL:

curl -sI "$(jq -r .url share.json)" | grep -iE '^(http|content-type|content-disposition|content-security-policy)'
HTTP/2 200
content-type: text/html; charset=utf-8
content-disposition: attachment; filename="page.html"; filename*=UTF-8''page.html
content-security-policy: sandbox; default-src 'none'; img-src 'self' data:; media-src 'self'; style-src 'unsafe-inline'

The type is right, but Content-Disposition: attachment tells the browser to save the file instead of displaying it, so your reader gets a download. The sandbox policy also keeps scripts in the file from running.

The page's relative style.css would resolve next to the file on the files host, where nothing exists:

curl -sI "$(dirname "$(jq -r .url share.json)")/style.css" | head -1
HTTP/2 404

This is by design. Per the content-serving headers, the files host serves images, audio, video, PDF, plain text, Markdown, CSV and JSON inline, and HTML, XML, JavaScript and CSS always as attachments. Use share when the reader should get the file itself.

Publish the folder instead

A folder with an index.html at its root is a site:

npx -y @instahost/cli publish ./site --ttl 1h --json > site.json

site.json holds the site URL, its separate delete token and its own claim link:

{
  "ok": true,
  "id": "2wd4h36sgoshscjgcsu2k3royn",
  "type": "site",
  "access": "unlisted",
  "url": "https://2wd4h36sgoshscjgcsu2k3royn.instahost.cloud/",
  "expires_at": "2026-12-03T12:04:43Z",
  "delete_token": "ihd_[redacted]",
  "access_token": null,
  "access_url": null,
  "claim_url": "https://console.instahost.dev/claim/2wd4h36sgoshscjgcsu2k3royn#ihc_[redacted]",
  "file_count": 3,
  "total_bytes": 400,
  "skipped": [],
  "warnings": []
}

The site gets its own host, whose root serves index.html without Content-Disposition or a sandbox policy, so the browser treats it as a normal web page:

curl -sI "$(jq -r .url site.json)" | grep -iE '^(http|content-type|content-disposition|content-security-policy)'
HTTP/2 200
content-type: text/html; charset=utf-8

Its assets are served from the same host, at their folder paths, with their own types:

for asset in style.css img/logo.svg; do
  curl -sI "$(jq -r .url site.json)$asset" | grep -iE '^(http|content-type)'
done
HTTP/2 200
content-type: text/css; charset=utf-8
HTTP/2 200
content-type: image/svg+xml; charset=utf-8

A folder without a root index.html is refused before anything is uploaded, with exit code 3. To see the error, put only page.html in a fresh folder:

mkdir pages
cp page.html pages/page.html
npx -y @instahost/cli publish ./pages --ttl 1h --json
{
  "ok": false,
  "error": {
    "code": "missing_index",
    "message": "./pages has no index.html at its root; a site needs one.",
    "details": {
      "path": "./pages"
    },
    "fix": "Add an `index.html` at the root of the directory, or share a single file with `share`.",
    "exit_code": 3
  }
}

Keep asset URLs relative

Use relative URLs like href="style.css" so the page also works from disk or when served under a path. A root-absolute URL like /style.css works at the root of an InstaHost site. To catch it before publishing, make a copy with a root-absolute link and run a preview:

cp -r site site-abs
sed 's|href="style.css"|href="/style.css"|' site/index.html > site-abs/index.html
npx -y @instahost/cli publish ./site-abs --ttl 1h --dry-run --json
{
  "ok": true,
  "dry_run": true,
  "type": "site",
  "files": [
    {
      "path": "img/logo.svg",
      "size": 114
    },
    {
      "path": "index.html",
      "size": 239
    },
    {
      "path": "style.css",
      "size": 48
    }
  ],
  "file_count": 3,
  "total_bytes": 401,
  "skipped": [],
  "warnings": [
    {
      "code": "root_absolute_reference",
      "message": "1 file(s) use root-absolute URLs (\"/app.js\"), which can break when a site is served under a path; use relative URLs (for example Vite base: \"./\")",
      "paths": [
        "index.html"
      ]
    }
  ]
}

The /app.js in the message is the CLI's generic example; paths names the file that triggered it. With Vite, set base: "./" and publish the build folder. See relative URLs, which also covers <base href="/">.

Choose who can open it

Share an HTML file with share --access private to give reviewers a token-protected download. To let visitors open the page as a website, publish its folder with --access public or --access unlisted. Access modes

Set how long it lives

--ttl 1h gave an expires_at one hour after creation. The default lifetime is 1 day and the minimum is 1 minute. Anonymous links last up to 7 days. A Console account key allows up to 90 days. Only an operator-issued key with persistence enabled can use --ttl never. Claiming a link keeps its original expiry. After expiry its URLs return 410 while the tombstone exists, then 404 after removal. See the size limits and daily quotas.

Delete the page

Use the delete_token from each JSON file to remove that artifact early. delete accepts the id or its URL:

npx -y @instahost/cli delete "$(jq -r .id share.json)" --token "$(jq -r .delete_token share.json)" --json
npx -y @instahost/cli delete "$(jq -r .url site.json)" --token "$(jq -r .delete_token site.json)" --json

Each delete printed one document:

{
  "ok": true,
  "id": "7k77gh2pp33soj54kwfktm2r6b",
  "status": "deleted",
  "deleted_at": "2026-12-03T11:04:46Z"
}
{
  "ok": true,
  "id": "2wd4h36sgoshscjgcsu2k3royn",
  "status": "deleted",
  "deleted_at": "2026-12-03T11:04:46Z"
}

Deletion takes effect on the next request, for the page and its assets:

curl -sI "$(jq -r .url share.json)" | head -1
curl -sI "$(jq -r .url site.json)" | head -1
curl -sI "$(jq -r .url site.json)style.css" | head -1
HTTP/2 410
HTTP/2 410
HTTP/2 410

The URLs return 410 during the seven-day tombstone period. You can remove the local JSON files after cleanup.

FAQ

Why does my HTML file download instead of opening?

Because it was shared as a file. The files host sends HTML with Content-Disposition: attachment and a sandbox policy. Publish the folder that contains it, with the page named index.html, to get a rendered page.

If I share only the HTML file, do its CSS and images come along?

No. share uploads exactly one file. In the test, the shared page's relative style.css answered 404. Publish the folder so the assets are served next to the page.

Do visitors need an account?

No. Anyone with an unlisted or public URL can open it, and creating the link needs no account either: the commands above ran anonymously. Cloudflare may still show a challenge page to a visitor it rates as a threat.

Can I update the page at the same URL?

No. Artifacts are immutable. Publish again to get a new URL, then delete the old artifact with its delete token.

Will search engines index my page?

Not by default: unlisted pages send noindex, nofollow. With --access public they may be indexed.

Try it

Use the publish command above with @instahost/cli on your own folder.

To let your coding agent share and publish for you, install the InstaHost skill. Interactive, in a terminal:

npx skills add instahost-dev/instahost

For agents and scripts, where no one can answer the prompts (-a names the agent):

npx skills add instahost-dev/instahost -a claude-code -y