Hacker News new | ask | show | jobs
by mg 1524 days ago
For static websites, is there any reason not to host them on GitHub?

Since GitHub Pages lets you attach a custom domain, it seems like the perfect choice.

I would expect their CDN to be pretty awesome. And updating the website with a simple git push seems convenient.

10 comments

Once you've used a couple more static hosts you'll find that gh pages is a second tier host at best. Lacks some basic configuration options and toolings, can be very slow to update or deploy, the cdn actually isn't as good as others, etc. Github pages is great for hobby projects and if you're happy with it by all means keep using it... but I wouldn't ever set up a client's production site on it.

If you're curious, Netlify is one popular alternative that is easy to get in to even without much experience. I would say even at the free tiers Netlify is easily a cut above Github for static hosting, and it hooks into github near perfect straight out of the box if that is something you value.

> is there any reason not to host them on GitHub?

Because some people may not want to depend even more on Big Tech (i.e. Microsoft) than they already do

>For static websites, is there any reason not to host them on GitHub?

One reason would be if your site violates the TOS or acceptable use policy. GitHub bans "excessive bandwidth" without defining what that is for example. For a small blog about technology you are probably fine.

Wanting to own your own web presence is reason not to host them on GitHub.

For static websites, CDNs are largely unnecessary. My potato of a website hosted from a computer in my living room has been on the front page of HN several times without as much as increasing its fan speed.

It took Elon Musk tweeting a link to one of my blog posts before it started struggling to serve pages. I think it ran out of file descriptors, but I've increased that limit now.

Was it through a VPN? I feel like revealing my home IP to random people on the internet is a bad move.
No VPN. I have the ports fairly well tightened down, though. I'm exposed to a zero-day in iptables itself or something, but whatever. Even if someone got in it would be an inconvenience at worst. It's not like I'm making money off this stuff.
Are you able to describe how you run yours? I scummed your blog but didn’t see anything about it.
The static content is just nginx loading files straight off a filesystem. The dynamic content (e.g. the search engine) is nginx forwarding requests to my Java-based backend.
You can serve massive amount of static requests from any potato really, it's a solved problem.
I'm sure their CDN is great, and I've used it in the past; however, I like to self-host as a hobby.
> For static websites, is there any reason not to host them on GitHub?

I don't like github pages because it's quite slow to deploy. Sometimes it takes more than a couple of minutes just to update a small file after the git push.

I don't think you can set a page or URL on github to return a 301 moved permanently response or similar 3xx codes. This can really mess up your SEO if you have a popular page and try to move off github, you'll basically lose all the clout on the URL and have to start fresh. It might not matter for stuff you're just tossing out there but is definitely something to consider if you're putting a blog, public facing site, etc. there.
I have a few 301 redirects setup on github pages

    $ curl https://nobodywasishere.github.io # moved to https://blog.eowyn.net

    <html>
    <head><title>301 Moved Permanently</title></head>
    <body>
    <center><h1>301 Moved Permanently</h1></center>
    <hr><center>nginx</center>
    </body>
    </html>

    $ curl https://blog.eowyn.net/vhdlref-jtd # moved to https://blog.eowyn.net/vhdlref

    <html>
    <head><title>301 Moved Permanently</title></head>
    <body>
    <center><h1>301 Moved Permanently</h1></center>
    <hr><center>nginx</center>
    </body>
    </html>
Is that coming back with a HTTP 200 response though and the made up HTML page? That doesn't seem right... at least, I dunno if google and such would actually index your page at the new URL vs. just thinking "huh weird looks like blog.eowyn.net is now called '301 Moved Permanently', better trash that down in the rankings".
It shows up as a proper 301 when I load up the URL in Firefox. The question is, how?
One of the Jekyll plugins that GH Pages supports[0] is jekyll-redirect-from, which lets you put a `redirect_to` entry in a page's front matter.

[0]: https://pages.github.com/versions/

I found this example of another repo that is using the same trick: https://github.com/kotokaze/kotokaze.github.io

    ~ % curl -i 'https://kotokaze.github.io/'
    HTTP/2 301 
    server: GitHub.com
    content-type: text/html
    permissions-policy: interest-cohort=()
    location: http://github.kotokaze.net/
For the latter, `<meta http-equiv="refresh" content="0; URL=https://blog.eowyn.net/vhdlref" />` in the `<head>`
Wow, nice yeah I'd love to know how github supports configuring a URL to 301 redirect!
Yea, no.

A 301 (or 302) redirect means setting the status code header to 301 and providing a location header with the place to redirect to. Last I checked GitHub doesn't allow any of this, or setting any other headers (like cache-control). To work around this, I've been putting cloudflare in front of my site which lets me use page rules to set redirects if necessary.

Netlify FTW — For the rewrite rules alone.
Well, not everything is open source.
Can you do SSL?
Yes, since 2018.