Static websites can be viewed without a server, locally, simply by opening them up in a web browser, and you can do whole big websites this way if you want. But there are limitations and drawbacks, which is why people and systems use local servers for static websites.
One of the reasons you may be asking is because using many of the popular static site generators, like Jekyll, requires that you tell the system to --serve
it (or similar), creating a local server for the static site. But if it's static, why do you need a server?
Here are a few reasons:
- only relative links are safe (
/
as a link to home is broken, as is referencing /css/something.css
, since /
is the root of your computer, not the site);
- relatedly, directory-level links fail (
blog/
shows the files under that directory, instead of looking for blog/index.html
or similar);
- and browsers treat local files differently among themselves and between them and hosted files (Chrome limits AJAX calls, IE uses a different protocol from everyone else, etc.).
So, no, you don't need it, but you do need it if you want those things.
save page as
) or with a tool like httrack or wget. Those cases do most of the things you're asking about.