7 ms·
Ask HN: What's the simplest static website generator?
I've tried Jekyll in the past but the setup is a bit overwhelming and it gets complicated super fast. I am looking for something where I can keep my header and footer separate and then include them in every other page. That's it. No CMS and no blog. Is there something which handles this well and is easy to set up?
I use Cloudflare Pages to host my website
- stop50 3y agoi liked hugo, but its a little harder to set up.
- skilled 3y agoUgh, this might be an overkill suggestion but Next.js is really easy to work with, and your goal can be accomplished super easily. Cloudflare page for deploying Next.js static site: https://developers.cloudflare.com/pages/framework-guides/nextjs/deploy-a-static-nextjs-site/ https://developers.cloudflare.com/pages/framework-guides/nex... On the sidebar they provide a ton of other guides for different generators, too.
- _heimdall 3y agoAstro is more simple than NextJS in my opinion, though even that feels like overkill for an SSG that's only needed to keep the header/footer consistent.
- adityaathalye 3y agoPandoc can be your friend. My site maker [1] is built around it. I think a hundred or so well-chosen lines of your favourite scripting language can do wonders. Mine is ~300 lines of Bash because I over-engineered a thing or two for kicks. The core of it is maybe 50 lines. [1] https://github.com/adityaathalye/shite https://github.com/adityaathalye/shite The README documents the architecture and rationale. Maybe it will help you figure out yours. Happy hacking!
- Cerium 3y ago+1 for Pandoc. Something like 100 lines of python extracts tagged documents from my Emacs org docs, converts to html and fixes links.
- rozenmd 3y agoAstro, it works very well on Cloudflare Pages.
- 082349872349872 3y agoThe r file command in sed(1) copies the contents of file to standard output; the rest is a simple matter of programming.
- 082349872349872 3y agoIf you all don't like sed(1), then use awk(1); I just hadn't recommended that approach because it'd be too simple: like with poetic form, if you want to do something interesting, you've got to choose some constraints.
- cpach 3y agoHugo without a theme and some simple CSS could do that. Feel free to clone this repo: https://github.com/cpach/piper https://github.com/cpach/piper
- FLpxpyJ 3y agoHugo has gotten easier recently to get up and running. Seems to come prepackaged with a simple, workable "template" when you create a new site. :)
- snarkyturtle 3y agoIts templating language is anything but simple, however.
- cpach 3y agoIt has a bit of learning curve, that’s for sure. This makes me curious though, have you found any better templating system?
- satvikpendem 3y agoZora is nice, written in Rust so there's really no setup compared to the Ruby gems mess that is Jekyll.
- snarkyturtle 3y agoI think you're thinking about Zola: https://github.com/getzola/zola https://github.com/getzola/zola But yes, if I were to recommend something, it'd be Zola given that there's just one executable that you need to run and there's absolutely no setup required.
- satvikpendem 3y agoYep Zola nor Zora, it's pretty nice.
- thibaultamartin 3y agoWe used Zola for https://matrix.org https://matrix.org and it was an overall pleasant experience! One major upside of Zola is that it's very stable, so you don't end up updating your dependencies every other day. One significant downside is that Zola seems to be sometimes a bit creative with the slugs generation, which can generate slug collisions where there shouldn't be any. It's possible to override them manually though.
- yawpitch 3y agoFor a use case that straightforward isn’t the simplest SSG going to be: cat header.html body.html footer.html > page.html ??
- adriangrigore 3y agoYou might enjoy mine https://mkws.sh/ https://mkws.sh/. It's shell based.
- dave333 3y agoI am getting the following error on a 64bit Windows 10 machine: ./bin/pp: cannot execute binary file: Exec format error Is it because it's a 32 bit binary?
- dave333 3y agoDigging a bit apparently it's a Linux binary and Windows would need a version compiled from source.
- adriangrigore 3y agoYup! :) You could use https://www.msys2.org/ https://www.msys2.org/ I think!
- JonChesterfield 3y agoI use GNU make and obsidian. Write content in markdown, feed it to https://github.com/commonmark/cmark https://github.com/commonmark/cmark to create html. I intended to splice files together using xslt but echo and cat written in the makefile sufficed. Plumbing is a bit obfuscated, not sure I've written it down anywhere. I write/edit files in obsidian or emacs. The obsidian sync feature copies those to a pi5 which also runs obsidian. That stashes whatever is in the directory into a fossil repo as a backup / sync to other machines mechanism. Something runs make periodically to rebuild the site which gets copied back into obsidian and thus ends up back on whatever device I'm using to edit the files. A simpler setup would involve committing markdown to a github repo and having a cron/make somewhere pull from that, rebuild the site, commit to the same or a different github repo.
- rsolva 3y agoI have used Caddy and its Server Side Include functionality (templates) to take care of repeating elements like header and footer etc. Does not get much simpler than that.
- VoodooJuJu 3y agoFor simply including a common header & footer in pages, any server side include (SSI) compatible server will do: Nginx, Apache, or Caddy. With SSI, your template for every page would basically look like this: <!DOCTYPE html> <html lang="en" class="no-js"> <head> <!--#include virtual="/ssi/head.html" --> <title></title> <meta name="description" content=""> </head> <body> <header> <!--#include virtual="/ssi/header.html" --> </header> <main> </main> <footer> <!--#include virtual="/ssi/footer.html" --> </footer> </body> </html> Making your own SSG is another good solution. They're easy to make, and you can tailor them to your own particular needs.
- torstenvl 3y agogcc -E was my first SSG. Run it on files like this... #include "templatestart.html" <!-- Content --> #include "tenplateend.html" Eventually a combination of wanting faster speed and NIH syndrome made me write my own that did significantly less parsing and processing. Then I built that into a live update system I called TCUP (torstenvl's content update program). It was a fun project, and ended up being the first non-trivial program I wrote (I was 17-18).
- gryzzly 3y agoYou can iterate over files and collect them into a map from paths to contents and use a 2kb snarkdown if you need markdown parsing.
- xyzzy4747 3y agoJust learn next.js and use it for simple sites and complicated ones. It hosts on a CDN for free and it's great.
- pwillia7 3y agoI like Hugo but it's still a little complicated -- Probably something more modern now tbh
- KingOfCoders 3y agoI use Hugo, have considered moving to something more modern, but it just works. All questions I have, are solved by ChatGPT, e.G. adding "_small" to jpgs. {{ $newImageURL := replace .Params.image ".jpg" "_small.jpg" }} so I don't need to learn or remember Hugo API. Quite recently I've added jamstack to reduce image sizes etc. to make the site faster.
- FergusArgyll 3y agoIt might not be the simplest but it was the first I learned so it's simple to me. Flask with jinja, then you just do {% extends layout.html %} etc. It might be overkill but it's not that hard
- SOLAR_FIELDS 3y agoHow many lines of Python does that end up being? Seems almost reasonable that this could fit in just a couple files
- FergusArgyll 3y agotechnically: from flask import Flask, render_template app = Flask(__name__) @app.route('/') def index(): return render_template('index.html') then a templates/ folder to keep layout.html, index.html etc. (and a static folder to keep js & css if you want)
- SoftTalker 3y agoNotepad. And a web server that can do includes.
- resonious 3y agoI would recommend just writing one yourself. It's not very hard, and the process of writing it will make you intimately familiar with how it works, so you won't feel overwhelmed. Just writing simple software feels way better than reading docs for an arcane tool that will change on you over time due to updates.
- michaelbuckbee 3y agoThere's a joke that goes like: "What's the first thing a developer does when they want to publish a blog post? Write a SSG."
- jjice 3y agoRelevant article with a graph that always gives me a laugh: https://blog.ashfaqfarooqui.me/post/blogging/ https://blog.ashfaqfarooqui.me/post/blogging/ I think may of us here are guilty of the right hand side.
- corytheboyd 3y agoYep just write your own, you can finish it in hour(s) if you yourself don’t overcomplicate things ;) You might come back to it in a year and hate it, but that’s also part of the SSG vision question every software engineer is required to go through.
- hiAndrewQuinn 3y agoHugo comes out of the box with headers and footers, but you'll probably want to grep around a bit before you understand them fully. I can still recommend my https://github.com/Siilikuin/minimum-viable-hugo https://github.com/Siilikuin/minimum-viable-hugo as a decent way to get started with a "gears first" approach to Hugo, even though recent developments have made it a bit outdated (in a good way!).
- Zealotux 3y agoMaybe a bit too elaborate for your taste, but I've used https://astro.build/ https://astro.build/ and loved every bit of it.
- thibaultamartin 3y agoI've used astro to build https://ergaster.org https://ergaster.org and it was very simple to work with. I host it on CloudFlare Pages and it works like a charm. I discovered it via one of Kevin Powell's videos: a 20 minutes tutorial to get started using Astro: https://www.youtube.com/watch?v=acgIGT0J99U https://www.youtube.com/watch?v=acgIGT0J99U I find it very simple to use as a developer, but there are quite a few things happening behind the scenes to make the site itself faster to load for users (e.g. it inlines the CSS so you don't have to load a separate sheet). The only downside of it is that it depends on a package manager.
- gdorsi 3y agoI suggest you to try out Eleventy (https://www.11ty.dev/ https://www.11ty.dev/) Quite simple to start, and a nice system to add some scripting and styles without the requirement of bringing in a framework.
- superchris 3y agoEleventy is pretty great! Highly recommend.
- tr3ntg 3y ago11ty user here too, converted from Jekyll. Very pleased with 11ty.
- mmusc 3y agoWould be my suggestion to.
- _kush 3y agoThis is exactly what I was looking for - thanks for the suggestion!
- dxs 3y agoI keep wondering about this, but you know what? I just keep using Blogger from Google. It's there, it works, and it's totally simple. I don't have to do any maintenance or worry about hosting or a domain name. Images go into my Flickr account, and I save a copy of each post's text, in case I ever want to do something else. But not so far. Been on Blogger since 2009.
- FigurativeVoid 3y agoNanoc! I never hear people talk about it, and it’s perfect. It can get complicated, but at the end of the day it’s just markdown to html.
- bradley_taunt 3y agoI made a very barebones one called barf. It's ~100 lines of code. https://barf.btxx.org https://barf.btxx.org
- focusedone 3y agoThis one is pretty good too: https://git.btxx.org/pblog https://git.btxx.org/pblog
- bradley_taunt 3y agoThanks! The only "issue" with pblog for what OP is requesting are the dependency requirements (ie. pandoc) Live demo for those wondering: https://pblog.btxx.org https://pblog.btxx.org
- rcarmo 3y agoWell, I built my static website generator out of Bottle - a single-file HTTP framework that has built-in templating. Bolting on a route that renders Markdown files is pretty simple, really, and a simple os.path.walk() and directly calling the routed function will let you do everything you need. So you only really need bottle and markdown in your requirements.txt, and around 100ish lines of code. Maybe a little more if you want to upload the results to Cloudflare directly (for which I’d use requests). You can rinse and repeat that with aiohttp and markdown if you want the async flavor (which is what I’d do these days if I hadn’t already “finished” mine). And, if you’re into LISP… https://github.com/rcarmo/sushy https://github.com/rcarmo/sushy might make for some fun reading.
- kcartlidge 3y agoBottle is soooo underrated.
- rcarmo 3y agoI've built dozens of things on it, some of which (like API servers) were surprisingly load-bearing. Upgrading some of those to aiohttp was trivial (but didn't help much performance-wise, since bottle was already so lightweight).
- exposition 3y agoAstro is amazing. I built my blog with it, hosted on CF pages [1]. DX is great. In most cases, ships absolutely zero JS to the client, meaning super fast load times. [1] https://www.yusufbirader.com/ https://www.yusufbirader.com/
- lyjackal 3y agoDo you have a preferred programming language? Whether building your own or using a framework, you’ll need to deal with the ecosystem. There’s lot is boots recommendations here, but if going for easy, I would make the initial decision based off what environment you’re already most comfortable with (JavaScript, Python, go, bash). In general I’d prefer an ssg over server side includes because there’s so many easy and free CDNs that you can use
- bachmeier 3y agoYou haven't given detailed specifications, but if you're writing the pages in markdown and you have Pandoc installed, this simple Makefile will do what you want, where website.html is your Pandoc template: files := $(patsubst %.md,%,$(wildcard *.md)) all: for f in $(files); do \ pandoc -s -o $$f.html --template=website.html $$f.md;\ done
- lelanthran 3y ago> I am looking for something where I can keep my header and footer separate and then include them in every other page. Are you married to markdown or is HTML markup sufficient[1]? Because just using a single 5-line web-component is sufficient for a shared header/footer on each page. I have a tiny web-component that does this (the shortest I saw in the wild is a 5-line one). Lets you do things like this: <html> <body> <zjs-include remote-src="./header.html"> </zjs-include> ... content ... <zjs-include remote-src="./footer.html"> </zjs-include> </body> </html> [1] Although markdown does let you include verbatim HTML, so you can use web-components directly within markdown too. A 2-line bash script to call pandoc to turn markdown into HTML is sufficient.
- staindk 3y agoI found it quite simple to use Jekyll, could be because I used a ""butler"" for it - found Poole[1] pretty good to get started with. Also I guess since I'm a Ruby dev a lot of Jekyll stuff made sense to me pretty quick. https://getpoole.com/ https://getpoole.com/
- jhoelzel 3y agogithub pages integration with jekyll. all you need is some setup and a git repo the rest ist done for you and unless you host traffic heavy content it will most likely be free forever.
- jread 3y agoMaterial for MkDocs is great for documentation centric websites.
- Brajeshwar 3y agoThat was what Server Side Includes[1] were exactly for. It comes built-in with Apache. I don't think Cloudflare Pages does it but looks one of the build tools supported by CloudFlare Pages, and choose the simplest one you find. Own and keep the content with the option to just keep changing the tool -- then keep trying till you find the ones that suits you best. 1. https://en.wikipedia.org/wiki/Server_Side_Includes https://en.wikipedia.org/wiki/Server_Side_Includes
- datascienced 3y agoThe identity function!
- brudgers 3y agoEmacs org mode?
- e12e 3y ago> I am looking for something where I can keep my header and footer separate and then include them in every other page. As others have said, this is a perfect fit for SSI. You could also deploy a simple php page (just using php as a template engine with server side/host support). I've experimented with m4 for something similar in the past. I would probably recommend going with Hugo, though: https://discourse.gohugo.io/t/solved-using-html-for-content-pages-instead-of-markdown/3374 https://discourse.gohugo.io/t/solved-using-html-for-content-... https://gohugo.io/getting-started/quick-start/ https://gohugo.io/getting-started/quick-start/ An article from 1997 on using m4 and make - would strongly recommend just using php cli these days...: https://tldp.org/LDP/LG/issue22/using_m4.html https://tldp.org/LDP/LG/issue22/using_m4.html For rolling your own in php, see: https://rosswintle.uk/2021/12/hang-on-php-is-a-static-site-generator/ https://rosswintle.uk/2021/12/hang-on-php-is-a-static-site-g... https://www.dah5.com/staticphp/ https://www.dah5.com/staticphp/
- tupolef 3y agoI'm currently using Zola, but a recent HN article reminded me to try Soupault along with Pandoc. Soupault is more geared to the use of external tools and plugins, which can make it more complicated. But if you already know the tools you're going to hook up to it, it's easier in the end. - https://github.com/PataphysicalSociety/soupault https://github.com/PataphysicalSociety/soupault - https://github.com/getzola/zola https://github.com/getzola/zola
- DimuP 3y agoGotcha! you should try webflow then - no piece of code, just UI
- ksimon 3y agoYou can check https://freeweb.me https://freeweb.me, when the editing part is completed, you download your website in zip archive, to upload anywhere. It's free. (disclaimer: it's one of my side projects)
- deleted 3y ago[deleted]
- mediumsmart 3y agoI use Jekyll just for the footer and nav/header. No blog and no cms. Not using sass or markdown. I installed it once, made everything local and turned it into a zip that a bash script unpacks into a name.local folder. Simple enough for me. Gem file just calls Jekyll current version and done.
- vcg3rd 3y agohttps://blot.im/ https://blot.im/ is the one that finally made it possible for me to use one without configuration of both a web server and a site generator (neither of which I can do) and keep my files "local" in a synced Dropbox folder.
- charlesrocket 3y agoZola is great! Easy to configure, simple workflow, and great docs.
- krapp 3y ago>I am looking for something where I can keep my header and footer separate and then include them in every other page. That's it. PHP. That's literally the one thing it does well. You should still use a framework (is Slim Framework still a thing? It's small, if it is) for routing and escaping but as long as your header and footer are pure HTML then you can just include them.
- hiljusti 3y agoCheck out "Dumb Site Generator" https://so.dang.cool/blog/2024-01-22-DSG-Dumb-Site-Generator https://so.dang.cool/blog/2024-01-22-DSG-Dumb-Site-Generator
- dave333 3y agoJust plain shell scripts has always worked for me.
- jusob 3y agoI use and like http://wintersmith.io/ http://wintersmith.io/ Very simple to use, enough plugins to cover most use cases.