Hosting · Free guide

How to run a static website locally and publish it online

A plain HTML website can run locally using a simple HTTP server. An Astro website has a development server for editing and a production build for deployment. You do not need a custom application server to publish ordinary static files.

By StaticLaunch · Four Media Group LLC

Prepare a website directory

Keep index.html and any CSS, JavaScript and images together in an organized folder. Opening index.html directly is useful for a quick check, but an HTTP server better represents how relative URLs and browser requests behave.

Run plain HTML locally

If Python 3 is installed, open a terminal in your website folder and run this example. Open http://localhost:8000 in your browser. Press Ctrl+C to stop. The loopback binding keeps the server local to your computer.

Example
python3 -m http.server 8000 --bind 127.0.0.1

Run an existing Astro project

Use a supported Node version and the project's instructions. If a valid package-lock.json exists, npm ci installs the locked dependencies. The development command normally prints a local URL to open.

Example
npm ci
npm run dev

Check the production build

The development server is not the final build. Generate the static output and preview it, then inspect the result for missing files, broken navigation and unexpected public secrets.

Example
npm run build
npm run preview

Deploy and verify a second update

Publish through a Git-connected Pages project for repeated builds, or Direct Upload if you already have compiled files. Verify the public HTTPS URL. Change a line of text and publish again to prove you can maintain the site.

Common questions

Do I need a local server for HTML?

Not always, but HTTP testing is useful for detecting behavior that differs from file URLs.

Can I deploy npm run dev?

That command runs a development server. Publish the generated static output instead.

References

Provider interfaces and limits can change. Consult the original documentation before changing production settings.