1. 29
  1.  

  2. 6

    I use Hugo, and I’m surprised how content I’m with it. I switched from a Jekyll clone, and despite its quirks (mostly originating from its Go ancestry) it is pretty usable and also pretty fast.

    What really interest me is why would I not use S3 and Cloudfront? Not that my blog written in a language spoken by a tiny population could possibly get overwhelmed with traffic, but my monthly fees are below 1$, and the site could handle practically unlimited load, should it face it. Also no hassle with hosting, security upgrades, SSL certificates. I have hosted it on a simple DO instance, and it was totally OK, yet AWS is superior in every possible respect for serving purely static pages.

    Instead of rsync the aws cli can be used to sync the bucket, it is incremental, and also pretty fast.

    1. 4

      I think it would be simple to use this tool in conjunction with S3/Cloudfront. I use Jekyll to build a local version of my site and then s3_website to push it to AWS. I like that the tool I use for building the site doesn’t tie me to a particular hosting strategy. (AFAICT the linked script only uses rsync to build the site locally in a target directory, not to deploy it to some remote host.)

      1. 2

        Sure it would be simple, it is just as simple as using rsync, I’m curious why would anybody run httpd and self-host given the drawbacks. Maybe I have a different usecase in mind, and that doesn’t let me see, or simply a matter of different preferences…

        1. 4

          I don’t think httpd is for self-hosting. I think it’s for previewing things locally (similar to jekyll’s serve feature).

          1. 2

            Thank you for your comments.

            Yes, rsync(1) is just to copy source files (html, css, md, etc) to ssg working directory. Yes, I use httpd(8) in debug mode (not like a daemon) locally, just for previewing. Why httpd -d? It’s already installed on OpenBSD by default. On macOS you can use python -m SimpleHTTPServer for the same purpose.

            1. 2

              I ran into problems with SimpleHTTPServer because it has no concurrency: a single client can block everything. You can work around this with the threading mixin, something like: https://kdecherf.com/blog/2012/07/29/multithreaded-python-simple-http-server/

          2. 1

            I’m curious why would anybody run httpd and self-host given the drawbacks.

            We are talking about serving static files, for a personal blog (out if a disk cache)…what are the drawbacks again?

            1. 1

              Even if you have only http facing the public internet you need to track the security reports. I found having to track CVEs for the few services I had on my machine too burdensome. Also you may need TLS, which also has its overhead, and hosting costs more than on S3 imho. If you need the machine for other purposes that may make the equation a bit different though.

              1. 3

                All true. But of course, some people do this kind of thing as a hobby, or as part of their jobs. Others might find it a fun learning exercise, and even rewarding.

                1. 2

                  Oh, it totally fell out of my sight. My bad.

                  I abandoned the pet server approach to have more of my limitd freetime devoted to my blog, creating content, as I already did enough ops at work.

        2. 2

          +1 to Hugo, I’d say “pretty fast” is underselling how ridiculously fast it is (at least compared to other popular static site generators).

          Re: why not S3+Cloudfront?

          I started with this a while ago. The problem is you end up using something like Route53 to get your custom domain and TLS, which ultimately ends up costing you $2-3/mo per domain altogether, which adds up pretty quickly when you have a bunch of domains. Not to mention the ordeal of managing AWS and their massive dashboards and weird config syntax.

          These days I use Github pages + Cloudflare for DNS/TLS in their free tier. If I were up for migrating again, I’d consider using Netlify which is great by all accounts and supports some basic dynamic forms that are handy for static sites (contact form, etc).

          1. 2

            I agree that Route53 costs can add up, but if your DNS provider can serve “APEX entries” you can get away without that, if I recall correctly (or maybe you can use Cloudfare then?). My single domain site takes <1€/mo, (Route53 + S3 + Cloudfront).

            Regarding Netlify: recently I have seen some useful/impressive tools they have open-sourced, so I’d also consider their services.

        3. 4

          If you’re interested in make-oriented systems, most of my lowdown sites use sblg for the templating part. By design Makefile-friendly. (Disclaimer: I wrote lowdown. And sblg.)

          Edit: simple example being divelog.blue.

          1. 2

            Hi Kristaps!

            Thank you for your awesome software. I’m a fan of BCHS and still learning C. I would use sblg too—it’s super fast and simple—but I needed some flexibility with rendering of my pages.

          2. 3

            http://entrproject.org/ beautifully captures a pattern I hack into makefiles with fsnotify & friends. Great project!

            1. 3

              I did something similar but in Ruby. I use it currently to generate static files for my blog, since Jekyll was overkill. It is very simple and there is room for improvement. It’s based on generate-md [1], great support for theming and config[2].

              [1] https://github.com/mixu/markdown-styles
              [2] config mockup

              1. 1

                Nice!

              2. 2

                I like the checkbox hack for showing a dark theme (even when JS is disabled).

                1. 1

                  Thank you. I use JS only to save the selected mode for the whole session. Without JS it goes back to the default state on page reload.

                2. 1

                  Why httpd? It’s only available for OpenBSD (and maybe other BSDs), and while I haven’t (yet) looked at the script, it would seem that it offeres no specific feature, which a more portable and lightweight server like darkhttpd would offer.

                  But otherwise, very interesting, I will consider maybe adopting and tweaking it to use on my site.

                  Also if the “pps” value is important, consider using cmark, since it’s known for it’s speed, that is beside it being commonmark compliant.

                  Edit: The choice makes sense from a OpenBSD perspective, and taking into consideration that it’s written for personal use, and not as a general replacment tool.

                  1. 7

                    Why httpd? It’s only available for OpenBSD (and maybe other BSDs), and while I haven’t (yet) looked at the script, it would seem that it offeres no specific feature, which a more portable and lightweight server like darkhttpd would offer.

                    I think the author is an OpenBSD user, and is probably trying to do as much with the base system (which includes httpd) and a minimum of additional packages as possible. darkhttpd is an additional package, and doesn’t come with a man page.

                    Also if the “pps” value is important, consider using cmark, since it’s known for it’s speed, that is beside it being commonmark compliant.

                    cmark hasn’t been ported to OpenBSD yet. Granted, the author could probably build it from source or do their own port, but that would defeat the point of the exercise.

                    1. 2

                      Yeah I guess I should write a manpage for darkhttpd at some point.

                      1. 1

                        is probably trying to do as much with the base system (which includes httpd) and a minimum of additional packages as possible

                        I understand that, but seeing that neither rsync, lowdown or entr are in the base system, it doesn’t seem too problematic. Especially since, this is my main point, httpd locks out all other systems from using it. To be fair, it’s a shell script and each to change, but it just seems like a weird design choice.

                        1. 5

                          I see what you’re talking about, but I don’t think it’s weird. I think the author is scratching their own itch, and documenting how they did it on the off chance that it’s useful or interesting to others. This isn’t an other-focused project with widespread adoption as a goal. If it were, then it would make more sense to just dump the output in a directory that could be transferred to a Apache2 or nginx host.

                          Personally, I’m more surprised that the author chose to build HTML and XML files directly from the shell script instead of creating templates and populating them using sed (and maybe awk). Now that would be badass.

                          1. 3

                            Yes, I’m an OpenBSD user. httpd(8) can be replaced with anything, it’s just for previewing. lowdown, entr, rsync are small and easy to install software:

                            # pkg_add lowdown entr rsync
                            

                            My HTML template is so tiny, I’ve decided to place it right into the shell script. Also it’s a bit faster than my version of my awk script.

                            Thank you!

                            1. 2

                              This is good stuff, and I had thought of extending it for my use case, but since I’m already getting what I want from Pelican I should stick with what works for me. Though I do use rsync to deploy; that’s baked into the Makefile. :)

                              1. 2

                                Cool! :)

                                One more point:
                                78.5MB ruby + jekyll + its dependences (25 gems)
                                0.82MB lowdown + rsync + entr

                      2. 6

                        The author mentions to use OpenBSD for servers and workstations, so why not? Portability isn’t so important for personal tools. And httpd is only used for the local preview feature and could easily replaced by any other http server, including python -m http.server. The 6 line httpd config is already included in the <160 lines of shell scripts.

                        The script is very short, reading such a thing before commenting generally improves sites like lobste,rs ;)

                        1. 2

                          I just finished reading it, since I couldn’t open it on my phone (the scripts content type is application/octet-stream making it un-openable on a phone). And as I guessed, it is easy to change, but I would still maintain that

                          cd "$DOCS" || exit
                          doas httpd -d -f "$conf"
                          ;;
                          

                          meaning that it requires root to run, as compared to darkhttpd which is fully functional without. It just seems like a simpler option, and again, I get it’s not a real problem, and I implied I would chance it if I were to use it anyways.

                          1. 3

                            meaning that it requires root to run

                            It requires root to drop privileges and chroot. I wouldn’t have it any other way.

                            Installing a third party daemon to avoid using the built-in features of the base system does not seem simpler really.

                            1. 1

                              Installing a third party daemon to avoid using the built-in features of the base system does not seem simpler really.

                              Well it does on a non-OpenBSD system (although one should remember that darkhttpd isn’t a daemon, but a single C file server, comparable to python -m http.server), which was the perspective I was looking at it. But from the authors point of view, his choice is reasonable.

                              1. 1

                                For systems with Ruby, the httpd function from the un package is the best choice. To require un and evaluate the httpd function:

                                $ ruby -run -e httpd
                                

                                Cute right?

                                Advantages over Python:

                                • multi-threaded
                                • supports SSL / TLS
                                • suitable for production deployment
                                • automatic indexes show modification time and file size
                                • don’t have to remember if it’s -m http.server or -m SimpleHTTPServer

                                More info: ruby -run -e help httpd

                                1. 2

                                  Folks, you are right, I’d use Python or Ruby on macOS, for example. Installing them on OpenBSD is not an option for me, they are huge.

                                  One of the reasons to replace Jekyll is having Ruby as a dependency. With my script all I need to build my site is: lowdown(1) and rsync(1). Also both can be replaced, but they are the fastest options I’ve tried so far.

                        2. 2

                          Being written by the OpenBSD team implies a certain amount of simplicity, correctness, security, and documentation. Ive never heard of darkhttpd. If those are only choices, I’d default on OpenBSD’s implementation unless I had good reason to do otherwise.

                          1. 2

                            I would agree that httpd would be a better choice, when it comes to actually hosting the content on the web, and one could only choose between the two. But

                            1. Neither is that the case (one has more options) and even then it would be bad design if necessitated the use of a server on a remote system, for static content
                            2. If I didn’t misunderand anything, httpd is used to locally debug and preview ones site. I would personally argue that in this case, security would be less important if the choice means the script isn’t usable on systems, httpd doesn’t run on (which I assume is something the author wants, since the script is written with POSIX compliance in mind)

                            So there seems to be a good reason, at least not to use httpd as the default server to locally preview ones site. And all I want, is to suggest darkhttpd since it actually is quite nice. suckless even recommends it, if that is a standard one can use. But in general it would be nice if one could use shell variables or something comparable to it

                            1. 2

                              I havent researched enough on either solution to say much more. Someone online just yold me it was their web server to replace more bloated or messy stuff. I was just saying some will default on stuff written by people that normally focus on quality or security. We got quite a few here that like the suckless stuff, too.

                              Your reasons for checking out the other one sound good, too. I have no issue with it. Just saying why some default on OpenBSD code.

                              1. 2

                                I’ll probably remove serve from my script in the future to keep it simple. Here is my use case right now:

                                Run httpd(8) as a daemon once:

                                # rcctl enable httpd
                                # printf 'server "localhost" {\n  listen on * port 80\n}\n' > /etc/httpd.conf
                                # doas rcctl start httpd
                                

                                Then run ssg watch for previewing:

                                $ cd src/romanzolotarev.com
                                $ DOCS=/var/www/htdocs ssg watch
                                
                        3. 1

                          I used to use bash + pandoc but couldn’t find an easy way to make an rss feed so made the easy switch to hugo

                          1. 2

                            Here’s an m4 macro that I use to generate my atom feed: https://github.com/technomancy/technomancy.us/blob/master/feed.m4

                            Not that I would, um, recommend that or anything.

                            1. 1

                              Haha, thanks!

                          2. 1

                            Updated the script: better customization, RSS feed generator, cleaner source code.