top | item 16346187

Ask HN: What is setup for your static blog generator?

70 points| chauhankiran | 8 years ago | reply

I have tried Jekyll, Hexo and few other static blog generator but not happy with theme. I want to build something in which I have total control. Like I have few scss/css files, few markup files and some other templates for design and based on them I can create a complete html files so that I can publish them on GitHub.

Many of you might have some scripts that generate your blog posts from some setup. If it is possible then can you share your setup configuration?

I am looking for following things with setup:

* I should have backup of my all posts if I want to move other other configuration. * I can easily tweak css or html. * I can generate a complete html blog that can be publish over GitHub or any other places.

90 comments

order
[+] nathan_f77|8 years ago|reply
I use Hugo, GitLab, and Netlify for blogs and landing pages. I highly recommend this combination. Hugo is blazingly fast and very customizable. It's written in Go, so it compiles hundreds of blog posts in less than a second. My old Jekyll and Octopress blogs used to take a few minutes.

Netlify is like Heroku for static sites. You can connect Netlify to GitLab (free private repos), and Netlify will build and deploy your site when you git push. I also use the Netlify nameservers for many of my domains, and it's really easy to set up SSL with Let's Encrypt. I can buy a domain on Namecheap, and have a new blog or landing page deployed in less than 5 minutes.

* https://gohugo.io/

* https://gitlab.com/

* https://www.netlify.com/

[+] seanwilson|8 years ago|reply
How do you find the template syntax with Hugo? I love the speed of it over Jekyll but I find the Hugo syntax really unintuitive sometimes. For example why {{ if or (isset .Params "alt") (isset .Params "caption") }} and not {{ if (isset .Params "alt") or (isset .Params "caption") }}?
[+] andrei_says_|8 years ago|reply
Is it possible to use scss and slim with Hugo? Does it support partials, an equivalent of liquid, investing data files?

These are the things that keep me with Jekyll and middleman.

[+] scrollaway|8 years ago|reply
I use Jekyll for most of my blogs. For my company's, we needed multiple authors including non-technical people, so we couldn't use git for that. I recently discovered Ghost which I highly recommend:

* https://ghost.org/

* Kickstarted in 2013

* Markdown-based

* Open source, self-hostable

* Hosted solution (https://ghost.org/pricing/) with support for your own domain name

* Beautiful themes out of the box with custom css/js on an article, site-wide or theme level

* Third party static site generation tools (https://github.com/axitkhurana/buster/, https://github.com/lexoyo/static-ghost)

Example blog (default theme): https://blog.ghost.org/

[+] bluehatbrit|8 years ago|reply
I've been using Ghost for a few years now, mostly because it interested me and looked nice to use. I've gone through a bunch of static blog generators and while they were cool (and cheap) I just really like the ability to login to my site, start drafting, have it auto-save and come back to it later. I'm not super fussed about having it version controlled, though I can export all my data (minus images) into a JSON format and version control that if I want.

I self host on the lowest Digital Ocean droplet which is now $5/mo and is plenty for my small time blog and I'm happy to pay $5/mo for the delight of using Ghost. Also with a cron job I can auto-update every few days and get the latest features without touching the box.

Ghost will auto-roll back if an update fails which is nice and I don't have that many viewers so if it goes down I don't mind so much right now.

A final bonus is that it uses handlebars for it's theme creation and rendering. I'm a node dev who uses handlebars for my own projects so editing my theme is a breeze.

[+] gmueckl|8 years ago|reply
I use Hugo (https://gohugo.io) on my local machine to create the website and upload the resulting static site to the server via rsync. The website templates and CSS sheets are all custom, so I get total control over the result.
[+] lucaspiller|8 years ago|reply
For anyone interested I created a privacy focussed theme for Hugo, with no third party scripts or assets:

https://github.com/lucaspiller/hugo-privacy-cactus-theme

I wanted a minimalist theme that's fast to load, but a lot of commonly cited examples are too extreme or look too dated for my liking. I wanted the same results, but something a bit more up to date and with code highlighting. You can see the end result on my blog (total network transfer 78kB):

http://www.stackednotion.com/blog/2016/07/09/setting-up-a-ne...

[+] tetraodonpuffer|8 years ago|reply
same here, I had created my custom themed html templates and css for pelican, but recently moved everthing to hugo. Complete control, no third party dependencies, no javascript (outside of pages with ttyrec recordings) and extremely fast to regenerate. Note this does assume you do your css preprocessing/minifying outside of Hugo though (I use compass), from Hugo's perspective your css is just another file.
[+] sago|8 years ago|reply
A static site generator is just a build tool. You need some way to say what your output files are, and what source files are needed to create them. This is usually hardcoded (with some parameters and ad-hoc hooks) in something like Jekyll, but could be specified with Make. I wrote a very simple timestamp checker in a couple of dozen lines of Python.

Then your scss/less->css is probably best done with the command line compiler, driven from your build tool.

And for HTML, take a template language you enjoy and write a simple driver script. If you want multiple templates, add metadata to your source files. In my case I want Markdown->HTML, using various templates, so I use YAML for the metadata, then Python's markdown compiler, and finally Jinja2 for templating. Again you can write the driver in a few dozen lines for your own purpose.

My build tools then calls The AWS API to send it to its S3 bucket, in most cases. But in one it commits to a github pages branch and pushes.

It is exceptionally simple to code your own static site generator, if you can do basic command line scripting. And doing it that way allows you to be very flexible and add things like uploading, version control, etc.

I think it's better off seen as a command line tool, than a special 'static blog generator' task. In general I think we are erring too far on the 'build a niche vertical app' rather than 'automate powerful general-purpose tools'.

[+] zeroping|8 years ago|reply
Not a direct answer, but I just wanted to point out how handy it is that you can publish to your public keybase directory, and have it hosted at keybase.pub, something like this:

https://abhi.keybase.pub/2016/02/15/git-and-keybasefs.html

The general gist is that keybase.io is promising that it will only serve data at abhi.keybase.pub that has been signed for by that user.

[+] dcreemer|8 years ago|reply
This is brilliant information. Thanks for sharing it.
[+] jakelazaroff|8 years ago|reply
This will probably forever be too half-baked to "release", but I wrote my own: https://github.com/jakelazaroff/adjective

It's written in Node and features multithreading and incremental builds for fast development.

I host on Netlify, which has continuous integration built in, so it builds and deploys the site every time I push to GitLab.

[+] dcreemer|8 years ago|reply
I'm also using Netlify (with Hugo). Their service is simple to use, and send to work quite well.
[+] stevenicr|8 years ago|reply
I use wordpress.

add a plugin from the repo "simply static" - generate the html files.

download, then ftp.

It's not elegant and lean like the others - but it's saved me a ton of time for the use cases I've used it for.

There is another decent static generator in the repo, but it failed on a recent site I was trying yesterday, so it's not on my currently using list.

I know it's possible to put wp dynamic files on a server and use a domain mapping plugin to generate files for a bunch of domains on the same server easily - could probably find someone smarter than me to add in this simply static plugin and mod it to shoot the files to the sub domains...

then just install a bunch of themes and other plugins to the main install - and might be kind of heavenly for a lot of situations.

Some of my wp sites need contact forms - so I'm leaving those live / dynamic. If it was easier to make and upload something like the coffee cup form builder files I'd convert a few more sites to static files this week.

If someone found a way to use the wordpress themes with these other generators it would be awesome. Then it would just be the few sites that need the extra plugins power that really need the wordpress php files and such. One can dream.

[+] ethomson|8 years ago|reply
Jekyll for my podcast's web site (https://allthingsgit.com/). I became a fan of Jekyll when I worked at GitHub, but I don't use GitHub Pages, I needed to scale it larger. (edit: in particular, I needed something that can host audio and video.) So my workflow is GitHub for hosting, and Visual Studio Team Services for CI builds. It monitors the GitHub repository and on commits to master, it runs Jekyll in a docker container. It then deploys to Azure, where I host the static web site. (I use Azure CDN for hosting the audio episodes.)

I would use VSTS for the whole pipeline, including the Git repository hosting, but I wanted to have a public repository, in case listeners wanted to submit pull requests. So far that hasn't happened, so I'm missing out on some of the VSTS features, but maybe it still will.

I also have a weekly newsletter (https://developertoolsweekly.com/) that uses a static site generator that I build myself. It's very Jekyll-inspired and uses Liquid templates, but instead of generally processing markdown, it takes a simple list of links and descriptions and emits a website as well as the HTML and plain text for the emails.

This workflow is similar, the generator is run in a Docker container, but this workflow is entirely VSTS and Azure.

[+] rayalez|8 years ago|reply
I'm very happy with using pelican for my blog:

https://startuplab.io/blog

It's very flexible, written in python, easy to customize, has plugins for any purpose.

I've made a custom theme, configured pelican a bit, and served with nginx on digital ocean(but it could as well have been served for free on github pages).

You can see the code and my custom theme here:

https://github.com/raymestalez/startuplab

[+] CogDisco|8 years ago|reply
I moved to Pelican from WordPress last year and it's been great. I wish there were more resources around for it, though.
[+] gshrikant|8 years ago|reply
Github pages + Bash + Python script. I have a very simple page layout for posts. A drafts directory maintains ASCIIDoc files for posts I'm writing.

After writing I run `post.sh` with the file as the argument. It invokes a Python script which generates the HTML and puts it in a directory for published posts sorted by date/month/year (e.g. published/2018/01/29). The Bash script generates a directory/link listing and an index page for the blog roll, followed by a "git push".

[+] 1wheel|8 years ago|reply
Jekyll was slow and hard to customize. A tiny script can convert a template + a directory of markdown files to a blog pretty easily.

Less code and configuration makes it easy to add custom features; I stuck incremental rebuilds and hot reloading into my blog while keeping it below 70 LOC:

https://github.com/1wheel/roadtolarissa/blob/master/index.js

[+] rwieruch|8 years ago|reply
I use Hugo [0] as a static website generator. They have plenty of themes [1] to choose from. You can still adjust it with basic knowledge in HTML/CSS. Afterward you can chose where to host it. You can use Github Pages [2] for free or pay for a service like DigitalOcean (starting with 5€ a month which scales well) [3]. I wrote a technical cheatsheet [4] on how to setup your own website with these ingredients. You can find a more elaborate way on how to host multiple static websites on Digital Ocean over here [5].

- [0] https://gohugo.io/

- [1] http://themes.gohugo.io/

- [2] https://pages.github.com/

- [3] https://www.digitalocean.com/

- [4] https://www.robinwieruch.de/own-website-in-five-days/

- [5] https://www.robinwieruch.de/deploy-applications-digital-ocea...

[+] cperciva|8 years ago|reply
I wrote my own for http://www.daemonology.net/blog/ . Basically it's a few template files, a /posts/ directory where I write the content of blog posts (one per file), and a shell script which generates all the html output.

Happy to share with anyone who wants it. Some day I'll get around to putting it up on github.

[+] deadcoder0904|8 years ago|reply
I started with Jekyll which had tons of freely available themes (no link) then went on to Hexo but it was slow ( https://100dayz.js.org ) compared to my next one Hugo (no link again) but Hugo was the fastest to generate since its made in Go. Then I used different documentation generator like Docute ( https://datastructures.js.org ) & Docsify, etc...

Then now. Personal opinion but I love Gatsby ( https://www.gatsbyjs.org ). For me, it is the best static site generator out there. Yes more than static site generator as it is a PWA by default. It is infinitely scalable. It prefetches content before its loaded (think about this as you get the data of Previous Blog Post & Next Blog Post when you are on the Current Blog Post). Its so fast that you will actually feel the speed. Also, with little efforts you can make it work offline too.

[+] nfrmatk|8 years ago|reply
I use Gutenberg (https://www.getgutenberg.io/) which provides built-in Sass compilation and live-reloading in a single binary. I just write Markdown and generate posts with Tera (https://github.com/Keats/tera ) templates for my HTML, so if I ever wanted to migrate to something else it would be trivial, but I'm a happy camper now.

When I'm ready to publish I just copy the public directory right to my webserver, but I could just as easily publish to GitHub or the like if I didn't enjoy maintaining my own domain.

[+] Keats|8 years ago|reply
I wrote my own as I wanted sass + syntax highlighting + a good template engine without having to install Node or similar (https://www.getgutenberg.io/). Not a lot of themes yet so it's better for peopl

In short, I just write my content in markdown, style in Sass and HTML in Tera (https://github.com/Keats/tera/) which is very similar to Jinja2.

I then automatically build & deploy from https://www.netlify.com/ on commits. Netlify will also get built-in support the next time they deploy their build image (ie all you need for your site to be deployed will be a file like https://github.com/Keats/gutenberg/blob/a2b55a927981727ce00a...) like Hugo does.

My own site is a bit difference as I have a DO instance for it but the script is simply copying the public folder to the server and have Caddy serve it.

[+] kettlecorn|8 years ago|reply
I had similar problems to yours: I wanted total control but I also wanted it to be quick and easy when I’m writing a new post or page.

So I made my own tool.

With this tool (which I dubbed ‘Wabi’) you put a bunch of files in a folder and the files are processed and copied to a corresponding location in an output folder.

Files with metadata at the top are processed specially and can be used as templates or to write markdown files that are turned into pages.

Wabi helps you setup Git integration so that when you run the “publish” command all local changes are immediately published to your website. I didn’t want to mess around with git stuff most of the time so I implemented that command so I could publish iteratively and quickly.

Wabi is sort of my answer to wanting control over how I build my website, while also wanting a tool that does not get in the way of the creative parts of making and running a website.

That said, it’s of no use to you because it’s completely undocumented and not polished, but probably over the next few months I’ll fix it up as I use it to create my own personal website. For those interested you can check out the source (it’s written in Go): https://github.com/kettle11/wabi

[+] Jeaye|8 years ago|reply
I run https://blog.jeaye.com/ on Github Pages, but I manually build with Jekyll locally, with a publish script, and then force push the built site + assets to the gh-pages branch. This allows me to use all sorts of Jekyll plugins which Github won't whitelist.

I'm currently writing a post detailing how all of this works, for anyone interested.

[+] city41|8 years ago|reply

    git subtree push --prefix build origin gh-pages  
  
is a nice simple way to push your build directory to the gh-pages branch.
[+] leejo|8 years ago|reply
> I'm currently writing a post detailing how all of this works, for anyone interested.

Yes please. I need to support localisation on a site I maintain, and for that will need one (or more) plugins that github don't support so would be interested in your setup.