Live data from Hacker News

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

github.com

41–50 of 63 posts

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

#41
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…

This is very impressive, and definitely more elegant than my approach. Getting make -j for free was definitely a major plus; before I started using a Python script to syntax highlight inline code, my site built in under a second... now it takes around 3.

I am honestly surprised to find Python is so slow in terms of start up time. This made me wonder if it was generating / searching for .pyc files, but a quick test revealed this is not the case:

  sh-4.3$ ls
  nop.py	nop.sh
  sh-4.3$ hexdump -C nop.py
  sh-4.3$ hexdump -C nop.sh
  sh-4.3$ time python3 nop.py

  real	0m0.064s
  user	0m0.048s
  sys	0m0.016s
  sh-4.3$ time sh nop.sh

  real	0m0.002s
  user	0m0.002s
  sys	0m0.000s
  sh-4.3$ python3 -m compileall .
  Listing '.'...
  Compiling './nop.py'...
  sh-4.3$ time python3 nop.py

  real	0m0.062s
  user	0m0.057s
  sys	0m0.004s

  sh-4.3$ python3 __pycache__/nop.cpython-35.pyc 
  sh-4.3$ time python3 __pycache__/nop.cpython-35.pyc

  real	0m0.060s
  user	0m0.048s
  sys	0m0.012s
I would add that shell can be surprisingly fast for certain tasks when used correctly. It's very easy to write slow (ba)sh code though, so most shell scripts wind up being fairly non-performent.

Edit: formatting.

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

#42
post #22

This is cool, and if I had the time I'd want to do something like this for automatically generating a google-photos style site from my Pictures directory. Also, if you're looking for a stable Python-based static site generator... I've been pretty happy with Pelican ( https://blog.getpelican.com/ ).

Agree, Pelican is easy to use and configure using Python.

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

#43
post #2

This seems to use the commonmark library to render Markdown? Can it render Pandoc flavour of Markdown? How widespread commonmark really is? Any popular sites using it? If I write my blog posts in commonmark is it safe to assume site generation tools 10 years from now will correctly render commonmark?

The main competitor to CommonMark is GFM, which is now based on CommonMark. https://githubengineering.com/a-formal-spec-for-github-markd...

I had checked out CommonMark a bit and blogged about it here, including an example of using it, and a bit about their goals:

CommonMark, a pure Python Markdown parser and renderer:

https://jugad2.blogspot.in/2014/09/commonmark-pure-python-ma...

One interesting point from them was this:

[ Reddit user bracewel, who seems to be a CommonMark team member, said on the Py Reddit thread:

eventually we'd like to add a few more renderers, PDF/RTF being the first.... ]

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

#45
post #25

Earlier quoted context omitted.

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.

Agreed. I concede!

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

#46

Writing static site generators is my favourite way of learning a language. Usually covers all the basics, libraries, FS, error checking and so on

Do you have an good example for this, yours or someone else's? I've never thought of that as a learning-a-language project.

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

#47
post #46

Writing static site generators is my favourite way of learning a language. Usually covers all the basics, libraries, FS, error checking and so on

Do you have an good example for this, yours or someone else's? I've never thought of that as a learning-a-language project.

Conveniently there seems to be a dozen or more static site generators written for every popular language, often with varying levels of complexity to learn from.

For example, Go: https://gohugo.io/

List: https://github.com/myles/awesome-static-generators

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

#48

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…

Yea. Thanks.

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

#49
post #26

Please don't use the number of lines as a metric for simplicity, it really doesn't mean anything

For two programs that do the same thing coded in the same language, I would pick the one with the least amount of lines but that doesn't mean that less work went into it... Probably the opposite
Post reply on HN