Can static websites be viewed without a server?
up vote
6
down vote
favorite
Really basic question, but I'm hoping to get some clarity here.
Let's say I have a static website with some html, some css and basic javascript. No web app to back it up. When testing the website locally, why do I need to run a web server to serve the content to the browser?
Is it because the relative paths in the URLs used in web pages are relative to the folder where the server is retrieving the content from and thus the various files included from the central HTML page can't quite get located on the file-system?
website webserver
add a comment |
up vote
6
down vote
favorite
Really basic question, but I'm hoping to get some clarity here.
Let's say I have a static website with some html, some css and basic javascript. No web app to back it up. When testing the website locally, why do I need to run a web server to serve the content to the browser?
Is it because the relative paths in the URLs used in web pages are relative to the folder where the server is retrieving the content from and thus the various files included from the central HTML page can't quite get located on the file-system?
website webserver
2
A good example of when a static website works without a webserver is when you save a website, either from a browser (save page as
) or with a tool like httrack or wget. Those cases do most of the things you're asking about.
– Journeyman Geek♦
Jan 30 '13 at 2:15
add a comment |
up vote
6
down vote
favorite
up vote
6
down vote
favorite
Really basic question, but I'm hoping to get some clarity here.
Let's say I have a static website with some html, some css and basic javascript. No web app to back it up. When testing the website locally, why do I need to run a web server to serve the content to the browser?
Is it because the relative paths in the URLs used in web pages are relative to the folder where the server is retrieving the content from and thus the various files included from the central HTML page can't quite get located on the file-system?
website webserver
Really basic question, but I'm hoping to get some clarity here.
Let's say I have a static website with some html, some css and basic javascript. No web app to back it up. When testing the website locally, why do I need to run a web server to serve the content to the browser?
Is it because the relative paths in the URLs used in web pages are relative to the folder where the server is retrieving the content from and thus the various files included from the central HTML page can't quite get located on the file-system?
website webserver
website webserver
asked Jan 30 '13 at 2:02
glitch
405168
405168
2
A good example of when a static website works without a webserver is when you save a website, either from a browser (save page as
) or with a tool like httrack or wget. Those cases do most of the things you're asking about.
– Journeyman Geek♦
Jan 30 '13 at 2:15
add a comment |
2
A good example of when a static website works without a webserver is when you save a website, either from a browser (save page as
) or with a tool like httrack or wget. Those cases do most of the things you're asking about.
– Journeyman Geek♦
Jan 30 '13 at 2:15
2
2
A good example of when a static website works without a webserver is when you save a website, either from a browser (
save page as
) or with a tool like httrack or wget. Those cases do most of the things you're asking about.– Journeyman Geek♦
Jan 30 '13 at 2:15
A good example of when a static website works without a webserver is when you save a website, either from a browser (
save page as
) or with a tool like httrack or wget. Those cases do most of the things you're asking about.– Journeyman Geek♦
Jan 30 '13 at 2:15
add a comment |
2 Answers
2
active
oldest
votes
up vote
4
down vote
accepted
Can static websites be viewed without a server?
Yes.
When testing the website locally, why do I need to run a web server to serve the content to the browser?
You don't.
Is it because the relative paths in the URLs used in web pages are relative to the folder where the server is retrieving the content from and thus the various files included from the central HTML page can't quite get located on the file-system?
No.
Just to clarify, I'm aware that you can load any page on disk into your browser. However, will the local files linked in the html (e.g. <link href="css/mycss.css [...]/> or <script src="js/foo.js" [...]</script>) be referenced correctly? Is there a way to have the same URL work for both the way you showed, and when the same website is served through a server?
– glitch
Jan 30 '13 at 2:08
1
Great, thanks for taking the time to put that together :)
– glitch
Jan 30 '13 at 2:25
1
Back in ancient times before we added a CGI shopping cart, this was the way we tested for broken links. Xenu link sleuth on a local disk copy beat wasting time on the slow internet of the day. After implementing the shopping cart, we had to build an internal test server for running the CGI efficently for testing.
– Fiasco Labs
Jan 30 '13 at 2:53
2
@glitch//
is protocol-relative, so I think you'll end up withfile://[whatever]/ajax.googleapis.com/...
. Which is what you're asking for.
– ta.speot.is
Jan 30 '13 at 6:39
1
This answer is pat to the point of being wrong. You can absolutely put whole static websites together without serving them, but relative-vs-absolute links, as you suspect, @glitch, AND differences in how browsers treat local files (protocols differ, sandbagging happens) are why people use static local servers.
– D_N
Dec 3 '15 at 4:32
|
show 7 more comments
up vote
4
down vote
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 forblog/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.
add a comment |
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
4
down vote
accepted
Can static websites be viewed without a server?
Yes.
When testing the website locally, why do I need to run a web server to serve the content to the browser?
You don't.
Is it because the relative paths in the URLs used in web pages are relative to the folder where the server is retrieving the content from and thus the various files included from the central HTML page can't quite get located on the file-system?
No.
Just to clarify, I'm aware that you can load any page on disk into your browser. However, will the local files linked in the html (e.g. <link href="css/mycss.css [...]/> or <script src="js/foo.js" [...]</script>) be referenced correctly? Is there a way to have the same URL work for both the way you showed, and when the same website is served through a server?
– glitch
Jan 30 '13 at 2:08
1
Great, thanks for taking the time to put that together :)
– glitch
Jan 30 '13 at 2:25
1
Back in ancient times before we added a CGI shopping cart, this was the way we tested for broken links. Xenu link sleuth on a local disk copy beat wasting time on the slow internet of the day. After implementing the shopping cart, we had to build an internal test server for running the CGI efficently for testing.
– Fiasco Labs
Jan 30 '13 at 2:53
2
@glitch//
is protocol-relative, so I think you'll end up withfile://[whatever]/ajax.googleapis.com/...
. Which is what you're asking for.
– ta.speot.is
Jan 30 '13 at 6:39
1
This answer is pat to the point of being wrong. You can absolutely put whole static websites together without serving them, but relative-vs-absolute links, as you suspect, @glitch, AND differences in how browsers treat local files (protocols differ, sandbagging happens) are why people use static local servers.
– D_N
Dec 3 '15 at 4:32
|
show 7 more comments
up vote
4
down vote
accepted
Can static websites be viewed without a server?
Yes.
When testing the website locally, why do I need to run a web server to serve the content to the browser?
You don't.
Is it because the relative paths in the URLs used in web pages are relative to the folder where the server is retrieving the content from and thus the various files included from the central HTML page can't quite get located on the file-system?
No.
Just to clarify, I'm aware that you can load any page on disk into your browser. However, will the local files linked in the html (e.g. <link href="css/mycss.css [...]/> or <script src="js/foo.js" [...]</script>) be referenced correctly? Is there a way to have the same URL work for both the way you showed, and when the same website is served through a server?
– glitch
Jan 30 '13 at 2:08
1
Great, thanks for taking the time to put that together :)
– glitch
Jan 30 '13 at 2:25
1
Back in ancient times before we added a CGI shopping cart, this was the way we tested for broken links. Xenu link sleuth on a local disk copy beat wasting time on the slow internet of the day. After implementing the shopping cart, we had to build an internal test server for running the CGI efficently for testing.
– Fiasco Labs
Jan 30 '13 at 2:53
2
@glitch//
is protocol-relative, so I think you'll end up withfile://[whatever]/ajax.googleapis.com/...
. Which is what you're asking for.
– ta.speot.is
Jan 30 '13 at 6:39
1
This answer is pat to the point of being wrong. You can absolutely put whole static websites together without serving them, but relative-vs-absolute links, as you suspect, @glitch, AND differences in how browsers treat local files (protocols differ, sandbagging happens) are why people use static local servers.
– D_N
Dec 3 '15 at 4:32
|
show 7 more comments
up vote
4
down vote
accepted
up vote
4
down vote
accepted
Can static websites be viewed without a server?
Yes.
When testing the website locally, why do I need to run a web server to serve the content to the browser?
You don't.
Is it because the relative paths in the URLs used in web pages are relative to the folder where the server is retrieving the content from and thus the various files included from the central HTML page can't quite get located on the file-system?
No.
Can static websites be viewed without a server?
Yes.
When testing the website locally, why do I need to run a web server to serve the content to the browser?
You don't.
Is it because the relative paths in the URLs used in web pages are relative to the folder where the server is retrieving the content from and thus the various files included from the central HTML page can't quite get located on the file-system?
No.
edited Jan 30 '13 at 2:18
answered Jan 30 '13 at 2:04
ta.speot.is
13.4k22546
13.4k22546
Just to clarify, I'm aware that you can load any page on disk into your browser. However, will the local files linked in the html (e.g. <link href="css/mycss.css [...]/> or <script src="js/foo.js" [...]</script>) be referenced correctly? Is there a way to have the same URL work for both the way you showed, and when the same website is served through a server?
– glitch
Jan 30 '13 at 2:08
1
Great, thanks for taking the time to put that together :)
– glitch
Jan 30 '13 at 2:25
1
Back in ancient times before we added a CGI shopping cart, this was the way we tested for broken links. Xenu link sleuth on a local disk copy beat wasting time on the slow internet of the day. After implementing the shopping cart, we had to build an internal test server for running the CGI efficently for testing.
– Fiasco Labs
Jan 30 '13 at 2:53
2
@glitch//
is protocol-relative, so I think you'll end up withfile://[whatever]/ajax.googleapis.com/...
. Which is what you're asking for.
– ta.speot.is
Jan 30 '13 at 6:39
1
This answer is pat to the point of being wrong. You can absolutely put whole static websites together without serving them, but relative-vs-absolute links, as you suspect, @glitch, AND differences in how browsers treat local files (protocols differ, sandbagging happens) are why people use static local servers.
– D_N
Dec 3 '15 at 4:32
|
show 7 more comments
Just to clarify, I'm aware that you can load any page on disk into your browser. However, will the local files linked in the html (e.g. <link href="css/mycss.css [...]/> or <script src="js/foo.js" [...]</script>) be referenced correctly? Is there a way to have the same URL work for both the way you showed, and when the same website is served through a server?
– glitch
Jan 30 '13 at 2:08
1
Great, thanks for taking the time to put that together :)
– glitch
Jan 30 '13 at 2:25
1
Back in ancient times before we added a CGI shopping cart, this was the way we tested for broken links. Xenu link sleuth on a local disk copy beat wasting time on the slow internet of the day. After implementing the shopping cart, we had to build an internal test server for running the CGI efficently for testing.
– Fiasco Labs
Jan 30 '13 at 2:53
2
@glitch//
is protocol-relative, so I think you'll end up withfile://[whatever]/ajax.googleapis.com/...
. Which is what you're asking for.
– ta.speot.is
Jan 30 '13 at 6:39
1
This answer is pat to the point of being wrong. You can absolutely put whole static websites together without serving them, but relative-vs-absolute links, as you suspect, @glitch, AND differences in how browsers treat local files (protocols differ, sandbagging happens) are why people use static local servers.
– D_N
Dec 3 '15 at 4:32
Just to clarify, I'm aware that you can load any page on disk into your browser. However, will the local files linked in the html (e.g. <link href="css/mycss.css [...]/> or <script src="js/foo.js" [...]</script>) be referenced correctly? Is there a way to have the same URL work for both the way you showed, and when the same website is served through a server?
– glitch
Jan 30 '13 at 2:08
Just to clarify, I'm aware that you can load any page on disk into your browser. However, will the local files linked in the html (e.g. <link href="css/mycss.css [...]/> or <script src="js/foo.js" [...]</script>) be referenced correctly? Is there a way to have the same URL work for both the way you showed, and when the same website is served through a server?
– glitch
Jan 30 '13 at 2:08
1
1
Great, thanks for taking the time to put that together :)
– glitch
Jan 30 '13 at 2:25
Great, thanks for taking the time to put that together :)
– glitch
Jan 30 '13 at 2:25
1
1
Back in ancient times before we added a CGI shopping cart, this was the way we tested for broken links. Xenu link sleuth on a local disk copy beat wasting time on the slow internet of the day. After implementing the shopping cart, we had to build an internal test server for running the CGI efficently for testing.
– Fiasco Labs
Jan 30 '13 at 2:53
Back in ancient times before we added a CGI shopping cart, this was the way we tested for broken links. Xenu link sleuth on a local disk copy beat wasting time on the slow internet of the day. After implementing the shopping cart, we had to build an internal test server for running the CGI efficently for testing.
– Fiasco Labs
Jan 30 '13 at 2:53
2
2
@glitch
//
is protocol-relative, so I think you'll end up with file://[whatever]/ajax.googleapis.com/...
. Which is what you're asking for.– ta.speot.is
Jan 30 '13 at 6:39
@glitch
//
is protocol-relative, so I think you'll end up with file://[whatever]/ajax.googleapis.com/...
. Which is what you're asking for.– ta.speot.is
Jan 30 '13 at 6:39
1
1
This answer is pat to the point of being wrong. You can absolutely put whole static websites together without serving them, but relative-vs-absolute links, as you suspect, @glitch, AND differences in how browsers treat local files (protocols differ, sandbagging happens) are why people use static local servers.
– D_N
Dec 3 '15 at 4:32
This answer is pat to the point of being wrong. You can absolutely put whole static websites together without serving them, but relative-vs-absolute links, as you suspect, @glitch, AND differences in how browsers treat local files (protocols differ, sandbagging happens) are why people use static local servers.
– D_N
Dec 3 '15 at 4:32
|
show 7 more comments
up vote
4
down vote
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 forblog/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.
add a comment |
up vote
4
down vote
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 forblog/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.
add a comment |
up vote
4
down vote
up vote
4
down vote
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 forblog/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.
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 forblog/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.
edited Nov 30 at 0:25
answered Dec 3 '15 at 6:25
D_N
1405
1405
add a comment |
add a comment |
Thanks for contributing an answer to Super User!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fsuperuser.com%2fquestions%2f543744%2fcan-static-websites-be-viewed-without-a-server%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
2
A good example of when a static website works without a webserver is when you save a website, either from a browser (
save page as
) or with a tool like httrack or wget. Those cases do most of the things you're asking about.– Journeyman Geek♦
Jan 30 '13 at 2:15