Show HN: Serve Static GitHub Pages Locally
github.com
github.com
The source code doesn’t do anything related with GitHub pages though.
It simply starts a file server with no more features than adding “.html” at the end of the URL.
You may want to change the default port from :80 to :8080 so people don’t have to set “-port” every time.
Also, in the README, you say that one of the implemented features is:
> 4. Check whether 404.html is a file, if so serve that file as a 404
But your code says otherwise [1] since there is no 404.html file in the repository.
[1] https://github.com/CurtisLusmore/ghp/blob/6b6e2bd/ghp.go#L25...
> The source code doesn’t do anything related with GitHub pages though.
I'm not sure what your point is here exactly. Although the source code makes no mention of GitHub Pages, and you're more than welcome to use this for anything you'd like, it was specifically built to mimic the behaviour of GitHub Pages w.r.t. the custom 404 and the dropped .html extension.
> You may want to change the default port from :80 to :8080 so people don’t have to set “-port” every time.
Good point. I personally use :80 a lot but I realise :8080 is pretty standard so will use that.
> But your code says otherwise [1] since there is no 404.html file in the repository.
The 404.html file is not part of this repository, it's part of the directory you are serving. See https://help.github.com/articles/creating-a-custom-404-page-...
Edit: In case it's not clear, this is designed for testing your GitHub Page site locally, before pushing. I'll update the Readme a bit to make this clearer.
> I'm not sure what your point is here exactly.
The title, "Serve Static GitHub Pages Locally," makes it sound like you're serving github pages. Maybe "serve local static pages like github does" would make it more clear.
What did you assume it did when you read the title?
I made this for myself, because my blog is served as static HTML via GitHub Pages and it's hard to test locally because all of my absolute paths break (links, imgs, scripts, css, etc.). I tried using the Python module http.server, but it doesn't support dropping the file extension (e.g. /about instead of /about.html). Thought somebody else doing the same might find this useful.
[1]: https://help.github.com/articles/setting-up-your-github-page...
However, to be honest, I see no advantage over Jekyll. A nice side-project to learn go on one hand, on the other, does not bring much to GitHub pages.
The only relevant header that is missing is the "Access-Control-Allow-Origin: *" That comes from github but not from you server.
In 404, github sends Content-Security-Policy: default-src 'none'; style-src 'unsafe-inline'; img-src data:; connect-src 'self'