Live data from Hacker News

Show HN: Makesite – A static site generator in 125 lines of Python

github.com

31–40 of 63 posts

Re: Show HN: Makesite – A static site generator in 125 lines of Python

#31
post #20

After using several different blogging platforms/tools, I finally decided to use instead a GitHub repo for my notes. Something really simple that lets me 1) create a note in plain Markdown, and 2) run a publi.sh script. That's all. After that, the note is already in my GitHub repo ready to be ctrl-f'ed when I'm looking for something I know I documented. In case anyone is interested I used this tool [0], but it was fi…

I'd recommend shellcheck[1] to help avoid common pitfalls with bash/sh, particularly in regards to word splitting.

[1] https://www.shellcheck.net/

Re: Show HN: Makesite – A static site generator in 125 lines of Python

#32

Personally, I used Jekyll for a while before switching to a simple Makefile based approach. I write everything in Markdown, which gets compiled via Pandoc, concatenated with a header and footer. I also recently started using pygments to generate colorized inline HTML to syntax highlight code blocks. If anyone is interested, I wrote up the process[1], although I have not updated the post with the pygments script yet.…

Fellow Jekyll refugee here. I also switched to the Makefile SSG approach for the much faster incremental rebuilds. Parallel speedup with make -j is also nice.

My SSG is called tinysite [1] [2]. Templates are jinja2. Posts are written in markdown with Pygments highlighting for fenced code blocks. Posts also have JSON frontmatter which can #include other JSON data files, and this is where it gets Make-y: all affected pages get rebuilt when a data file changes with the help of a `gcc -M`-style file dependency scanner. I use these frontmatter "data includes" for site wide metadata and for data driven pages like post indexes. There's also a dev server so you can quickly preview changes.

The biggest frustration I have with the Makefile + interpreted language approach is the slow startup time of interpreters these days. When every page requires a new interpreter process it really starts to add up, if not in incremental builds, then definitely in full rebuilds of larger sites. Some quick tests I did recently of `time $INTERPRETER -[c|e] ""`:

  node 6   ... 70ms
  ruby 2   ... 58ms
  python 2 ... 27ms
  perl 5   ...  5ms
  sh       ...  3ms
Perl compares quite favorably here, but I just can't bring myself to go back to it. I wish these other interpreters would get their startup time act together! I guess this is an argument for go / Hugo?

[1] https://github.com/acg/tinysite

[2] https://github.com/acg/alangrow.com

Re: Show HN: Makesite – A static site generator in 125 lines of Python

#33
post #20

After using several different blogging platforms/tools, I finally decided to use instead a GitHub repo for my notes. Something really simple that lets me 1) create a note in plain Markdown, and 2) run a publi.sh script. That's all. After that, the note is already in my GitHub repo ready to be ctrl-f'ed when I'm looking for something I know I documented. In case anyone is interested I used this tool [0], but it was fi…

I'd recommend shellcheck[1] to help avoid common pitfalls with bash/sh, particularly in regards to word splitting. [1] https://www.shellcheck.net/

Many thanks, I'll do.

Re: Show HN: Makesite – A static site generator in 125 lines of Python

#35
post #32

Personally, I used Jekyll for a while before switching to a simple Makefile based approach. I write everything in Markdown, which gets compiled via Pandoc, concatenated with a header and footer. I also recently started using pygments to generate colorized inline HTML to syntax highlight code blocks. If anyone is interested, I wrote up the process[1], although I have not updated the post with the pygments script yet.…

Fellow Jekyll refugee here. I also switched to the Makefile SSG approach for the much faster incremental rebuilds. Parallel speedup with make -j is also nice. My SSG is called tinysite [1] [2]. Templates are jinja2. Posts are written in markdown with Pygments highlighting for fenced code blocks. Posts also have JSON frontmatter which can #include other JSON data files, and this is where it gets Make-y: all affected p…

My (nowadays totally non-updated) website is built on similar approach with make+python (but with xml+xslt, which was the technology of the day in mid-00s) and the CPython's startup time was always issue even to the point that the incremental rebuilds essentially didn't make much sense (but writing the machinery was at least a fun experiment).

Re: Show HN: Makesite – A static site generator in 125 lines of Python

#36
A while ago I had written a tool called PySiteCreator.

It lets you create simple web sites (I originally thought of it for creating wikis, but later realized it was more general) by writing them purely in Python, using Python function calls to generate various HTML elements.

It uses a make-like approach (file timestamp checking between input and output files) and relies on a simple convention that users have to follow, of defining a Python function called create() in each .py file they write, where each .py file will be used by the tool to generate a corresponding .html file. Other than that, it places no restrictions on the user, and any arbitrary Python code can be used to generate or pull in data from anywhere, to be included in the web pages it creates.

Blog post about PySiteCreator here:

https://jugad2.blogspot.in/2009/11/early-release-of-pysitecr...

Source code here:

https://bitbucket.org/vasudevram/pysitecreator

Re: Show HN: Makesite – A static site generator in 125 lines of Python

#37
post #25

Earlier quoted context omitted.

Still takes one line, but it would be smaller in size touch i

No need to use such a bloated tool as "touch" to create a site. Your shell can do it: > index.html And there's ofcourse: index.html hello, world! from $(whoami) eof See also: m4.

    > index.html
You win.

Re: Show HN: Makesite – A static site generator in 125 lines of Python

#38
post #9

Earlier quoted context omitted.

Another free solution that may involve even less setup is Netlify's free tier, which includes 1-click HTTPS setup on a custom domain and reruns Hugo every time you push to the repo.

Moi? I love the idea of minimal. KISS is a wonderful thing. That said, anything more and a handful of pages (and especially something blog-y) needs search. Else the UX could take on too much friction. A couple weeks ago I saw something about a tool Facebook OS'ed for doing project documentation. I believe that was static and had search. I think. Unfortunately, I didn't go so far as to see if you could fake a (not for…

> That said, anything more and a handful of pages (and especially something blog-y) needs search. Else the UX could take on too much friction.

I've added search functionality to static sites before and the various JavaScript libraries available for this like lunrjs.com are super fast and easy to integrate. You can create a static search index at build time from a JSON file of your core content (probably a few 100KB compressed for many sites) and the search as you type functionality is instant which can be a better UX than other solutions.

Re: Show HN: Makesite – A static site generator in 125 lines of Python

#39

Earlier quoted context omitted.

Moi? I love the idea of minimal. KISS is a wonderful thing. That said, anything more and a handful of pages (and especially something blog-y) needs search. Else the UX could take on too much friction. A couple weeks ago I saw something about a tool Facebook OS'ed for doing project documentation. I believe that was static and had search. I think. Unfortunately, I didn't go so far as to see if you could fake a (not for…

> That said, anything more and a handful of pages (and especially something blog-y) needs search. Else the UX could take on too much friction. I've added search functionality to static sites before and the various JavaScript libraries available for this like lunrjs.com are super fast and easy to integrate. You can create a static search index at build time from a JSON file of your core content (probably a few 100KB c…

Hey, thanks for pointing this out. I didn’t even know to go looking for something like this, but it will be perfect for a site I have.

Re: Show HN: Makesite – A static site generator in 125 lines of Python

#40
post #30
post #23

how stupid is to measure code in terms of lines? Make all that a library then you can claim: A static site generator in only 3 lines of Python Measuring lines of codes is completely wrong. See the Scala trend were people race to find the shortest way to express something generating hard to understand code. 1) Code has to be written to be maintenable. 2) Code has to be written to be read by your coworkers. 3) The bott…

Unless you have put effort into squeezing as much logic as possible into each line, the less code the easier it is to maintain. With more code, more stuff can go wrong. It's not just because we are bad at writing code, we have probability against us. If the bug average is 1 bug per 100 LOC then 100 LOC will have less bugs then 10k LOC. We also have physics against us, reading and comprehending 10k LOC of code will ta…

That's not the point. Trying to squeeze the code in less lines as much possible is not the way to go if you loose clarity. Python coders keep repeting the mantra "less line of code" but in the mean time they keep typing: self. self. self.
Post reply on HN