Sssgen: Make static websites simple again
ehuber.info
ehuber.info
It can create a fair bit of boilerplate (relative to your average Python boilerplate), but the `if name == "__main__":` guard keeps this under control.
[0] https://github.com/edmund-huber/sssgen/blob/master/bin/sssge...
The guard is useful if your code is already composed of multiple functions/classes, which could be called from outside without running the full logic, but in this case I'm not sure it applies.
Every single change is instantly reflected on the page. A non-technical person can easily debug HTML (given countless resources ranging from MDN to W3Schools ~_~) than any templating language or what have you.
That said, for us devs this is yet another tool to play around with and maybe extract something useful for our own setups. Thank you.
I use Pandoc to convert to html and glue together the files. An index file lists which files go to the server. Some files are html only, others are also available as PDF.
Some of the things I do are less obvious. There is a rule to make the target «deadlinks» which iterates through the resulting html files and attempts to fetch the (first bytes) of each linke. The links which fail go into deadlinks.
There is also a target which lists spelling mistakes.
The deployment target is configured to fail if there are dead links or spelling-mistakes (there are also a few other sanity checks).
I tried using make, but then made my own 152-lines [0] of simple Python instead.
Some files on my site depend on others in non-trivial ways. For them I just use an index file of dependencies, and cat the index file in the dependencies list. It is a bit tedious to update the lists, but I have sanity checks in place to tell me when something is missing.
...and I fall back to my script which does "php + php -S to temporarily serve + wget to generate the actual static site".
sssgen seems like a breath of fresh air to me and I will actually use it. Thanks OP!!!
Also, thanks again for the sound decision of using Mako so I can actually have python code in my templates instead of wrestling with another "crippled" template language. And for jumping off the maddening "convention over configuration" wagon... I love configuration and explicitness for anything non-obvious
This is incorrect. The point of a static site generator is to generate static site content. You may use it in a simple manner, but there are many projects and companies that maintain huge, complex websites using static site generators like Middleman and Jekyll (along with various proprietary static site generators), in combination with content managers like Contentful. I'm talking hundreds if not thousands of pages, ecommerce, massive blog, multiple content types, etc. etc. I've worked on such projects, as have many others around here.
I'm glad that enlightened companies are increasingly open to using static generators for such websites, since many (possibly most) of them don't need to run PHP or Rails if the site doesn't have dynamic content on the frontend.
For such organizations, the point of static site generators is to produce vastly more secure and faster sites that are much easier to maintain and less expensive to host. Not to mention the ease of caching.
The OPs project, nice as it is for a small, simple project, would be impossibly simple for such projects. Anyone who tried to use it for a project of the scale I've described would just end up re-writing an inferior version of Middleman.
ssgen sounds like a cool project, and it also sounds like you're using the right tool for the job in your projects, but don't make the mistake of discounting a tool as useless or too complex just because it's not the right one for your purposes.
What do you think sssgen is missing that I could rip off of Middleman?
Or in general, what do you think is missing from sssgen to make it feasible to use for 100K+ -page sites? I'd really like to hear your thoughts.
1. I think a small, well-tested core like you're doing is great. I also think for your purposes, Mako templates are the right way to go, since they allow super flexible logic in the templates.
2. If you want some inspiration from a kinda sorta similar approach, take a look at Metalsmith and its plugin ecosystem if you haven't already.
3. A great asset to any static site generator would be a collection of "starter themes/sites" that already have things like a static asset pipeline set up (using Gulp, Grunt, or whatever floats your boat).
If you really want to accommodate the bigger static sites, a few critical features:
1. Super fast compile times. This is why Hugo is rapidly gaining ground despite not having a plugin API. When you have thousands of static files, it's not fun waiting 10 or 20 minutes for each compile (Middleman and Jekyll have gotten faster, but they're still slow relative to Hugo and the Node-based static site generators).
2. With huge sites that are built by large teams, flexible templates like Mako almost become a liability, since careless team members can overload logic into templates. For these teams, you may wish to offer an alternate template choice, like Jinja.
3. Some kind of feature similar to Middleman's dynamic proxy pages, which would allow users to dynamically generate hundreds of pages basic of Contentful's API or their own JSON files. See: https://middlemanapp.com/advanced/dynamic_pages/
Finally, features Middleman's url helpers have proved to be a significant help on large static sites I've worked on, since the URLs are no longer hard-coded. There are a lot of small but significant features like this: localization extensions, pagination, etc. But if you have a good plugin API, all of these things can be created and offered as plugins.
But again, I think your current approach is just fine. If I were you, I'd perfect a simple core generator and then try to build up the ecosystem.
And the whole Mako + yaml + tree variables is so sweat and simple.
Coincidentally, I've just started to re-do it as a python web app, that runs some limited dynamic processing (e.g. forms, logging, kudo-tracking, everything to keep it 100% self-hosted). I'm really interested if there are projects in this space that I'm not aware of, that I could just use...
That kind of inspired me to start a simple static website hosting service which is still in beta: http://www.statichosting.co/
I've tried all the other hosting options, and they are fine. I just never fell in love with any of them, so I made my own with a couple friends.
If you are interested in trying the beta, please sign up. We'll be opening it to more sites soon.
- how big are the zip files they can send?
- any limitation on the outgoing bandwidth?
- will the static websites be public or will it be possible to configure some sort of basic authentication?
- etc. (I'm sure you get the idea)
- I think the zip file size is nginx configurable and it's set to like 4 or 8 MB right now. - I don't have any bandwidth limitation at the moment, but if someone has a very high bandwidth site or wants to use the service to host/share files I'd have to cap those users somehow or maybe just charge more. - Right now they are public, but I'd be willing to explore basic auth if that's a requested feature.
In general. We are making a service that we want to exist and are trying to do the best for whoever decides to show up.
Thank you for those questions, I am too close to the product to even realize what people might ask, but those all seem obvious in retrospect.
What does "fairly complicated" mean here? An example would be nice.
That being said, for either Jekyll or Hugo, I've had to read >>200LOC in order to really understand a problem. :)