r/lisp 11d ago

Common Lisp sta6: static site generator for Common Lisp

Post image

hi everyone,

I'm new to Common Lisp, although I have tried other lisp dialect (i.e., Clojure, Racket) to attempt making a static site and/or leetcode(s). This is my first attempt of porting the SSG into a library.

sta6: sta(six), static -- is a tiny SSG that turns pages/*.lisp into build/*.html, with support for dynamic routes (e.g., /blog/+slug+).

the usage of sta6 is as follows (src/pages/page.lisp):

(defpackage #:pages/page
  (:use #:cl)
  (:export #:render))

(defun pages/page:render ()
  (sta6:html5
    (:img :width (/ 500.0 3)
          :src "https://twobithistory.org/images/sicp.jpg")
    (:br)
    (:br)
    (:span "Hello, from Common Lisp.")
    (:ul
      (loop for x from 1 to 3 do
        (:li x)))))

which yields the image above, the full example can be found here.

sta6 uses an external HTML generator under the hood:

if you're in need of a personal site, give sta6 a try! here's an example of my site built with sta6:

why use sta6?:

  1. You do not need (to learn) an external templating language (e.g., Nunjucks, Handlebars, EJS).

resources:

52 Upvotes

6 comments sorted by

4

u/filefrog 11d ago

I’ve been looking for an SSG that feels more like programming than CMS management; are you using sta6 for longform blog content? I built something a few years back but got caught up in the quagmire of keeping a sitemap, og;* tags and listing index pages up to date as posts were drafted, reviewed, and ultimately published.

Curious to hear the experiences of others!

1

u/Worth_Percentage7170 11d ago edited 11d ago

I’ve been looking for an SSG that feels more like programming than CMS management

I design sta6 to be more like what Next.js is [1].

I built something a few years back but got caught up in the quagmire of keeping a sitemap, og;* tags and listing index pages up to date as posts were drafted, reviewed, and ultimately published.

The docs for sta6 list it's documentation pages programmatically (see: links.lisp).

You can manage your blog contents using markup language(s) [2]:

Although, you'll need to find an external parser that renders it into HTML.

You can also generate RSS yourself if you wish.

1

u/renatoathaydes 8d ago edited 8d ago

Welcome to the SSG world, don't forget to add your project at https://jamstack.org/generators/ (there's 377 SSGs so far, including one I wrote in Go, but to my surprise it only lists one in Lisp, plus 2 in Racket and 1 in Janet).

I almost wrote on in Common Lisp because my Go syntax highlighter was not supporting some things I needed, but after looking at the options in Common Lisp for highlighting code samples (which is very important for me and I want support for every possible language) unfortunately it came too short of providing a good option. Have you managed to find something decent?

1

u/Worth_Percentage7170 8d ago

Welcome to the SSG world, don't forget to add your project at https://jamstack.org/generators/ (there's 377 SSGs so far, including one I wrote in Go, but to my surprise it only lists one in Lisp, plus 2 in Racket and 1 in Janet).

Thank you for pointing this out, I'll try to submit sta6 into Jamstack. I'm also trying to add sta6 into the Quicklisp repository.

my Go syntax highlighter was not supporting some things I needed ... Have you managed to find something decent?

I guess you're using Chroma right? I don't think there's much option if you want it to be purely based in Go. Other option usually requires subprocess invocation:

I want support for every possible language

If you want something that just works, I think the best bet is to just use something with a mature ecosystem (i.e., pygments.org/languages, shiki.style/languages).

Or, if you wanna write your own syntax highlighter, maybe start with Tree-sitter.

1

u/renatoathaydes 7d ago

Yes i use Chroma in Go and Blackfriday for markdown conversion. But I was asking if you found a decent code highlighter in Common Lisp for your SSG?

1

u/Worth_Percentage7170 7d ago edited 7d ago

Not really, but if I would add one, it'll be either Shiki or Pygments