A static site generator using Crystal

Hello!

Today has been my first day using Crystal. I’ve installed it on Ubuntu and had a lot of fun learning the first steps in your website. I really loved the code showing strawberries in the Beatles members list. I still have a long way to go, lots to learn, but, I would like to know if it is very hard to make a static site using crystal…

Jamstack has a list with hundred of static site generators:

https://jamstack.org/generators/

Unfortunately, I didn’t find the Crystal language among them…

I am really curious about website creation using crystal and site generator… could you send me a link where I could read more about this, please?

Thank you,

Alexandre.

Well I think static site generators are already a very common thing and you can get very many different flavours. And in general, it typically doesn’t matter that much what language the generator is written in. Having one in Crystal doesn’t immediately add some benefit over others written in Ruby, Python, JavaScript, Go etc.

That being said, I actually started one as an experiment: GitHub - straight-shoota/criss: Instantaneous static site site generator and server in Crystal
It’s mostly a PoC and hasn’t gotten much updates lately. But it’s able to build a couple websites as a drop-in replecement for Jekyll. It works pretty well, and it was fun to write it.
But again, I think it’s not that much valuable to have another SSG just to have one written in Crystal. That’s why it’s incomplete :man_shrugging:

1 Like

Hello Johannes!

Thank you for your comment, and the link. I will install it and build a website to see how it looks like.

I’ve built a static site generator using swift (tool: publish) but it does not have a paginator. I think it would be useful to have a blog with paginator…

Alexandre.

Hi again!

I tryed to build the site, but the command returned an error…

I took a screenshot and will upload it within this post.

(My system is Ubuntu Linux 20.4)

Was built using older Crystal version and hasn’t been updated to 1.x. If your goal is to find a static site generator in Crystal, just because its Crystal, don’t think you’ll have much luck. Are plenty of pretty robust options already out there.

1 Like

Hello Blacksmoke.

Thank you for your message.
Ok, I will give up.
Maybe I find another solution that fits what I am looking for…

As others have said, I don’t think there is anything specific to Crystal that would be for or against a static site generator.

In fact, it seems like the perfect project for you to start learning Crystal!

For what it’s worth, I’m planning on adding static site generation to my own Crystal project soon. The more the merrier!

3 Likes

I agree. The most important thing you can do to learn is to create things! Doesn’t matter if that thing already exists.

2 Likes

The two static website generators that I know are:

Of cause Hugo is faster, but it might be interesting to see if you can port Jekyll to Crystal and compare it to Hugo.

1 Like

I’m not going to create a static site anymore, but I want to keep learning the language.
I just bought an ebook from kobo.com called “Crystal Programming” and I am enjoying it very much!

1 Like

Been looking through various abandoned SSG in crystal to find one that uses markd. Yours appears to be a good candidate. I’m eventually planning on making a superset (based on commonmark) hopefully on top of markd for a static site project.

If I do end up getting it compiling again in modern Crystal, wondering if it should just be forked to something new or if you want contributions back. Very likely killing the sass and moving to tailwindcss if I do take this on since it’s a dead end these days. Might end up being easier doing my own project. Thoughts?

1 Like

I can’t wait for your updates!

About CSS frameworks, IMHO it’s a double sided sword because:

  • initially they accelerate development, mainly with the structure
  • then you start to fight it because its default styling is obviously not the style of your project

Because of that, I created a nano CSS framework https://github.com/alumna/alumna-css, which helps only with the structure and leave you free to style each project as you wish.

It includes Preflight.css, which is Tailwind’s base reset.

You don’t need to use Alumna CSS, but what I simply recommend is to avoid full-blown CSS frameworks, and to have just a basic recipe for the invisible structure.

Will have to take a look. I’ve been doing websites since the Geocities days, so know what you are talking about. Hate fighting css, fortunately ai helps a lot now, but I know how to get in the weeds with it even without that. I used to use sass back then and trying to remember the lesser known competitor, was it Less?

My little app I just did in Crystal originally was going to use a small css framework like pico or something else but getting columns and boxes just right was a pain. I know tailwind very well and recently had to update to newer version of Bootstrap at work, so am used to fighting heavy frameworks. Fortunately I think I have a working Makefile for even getting tailwind with FreeBSD and Crystal working now, so at least dev/CI workflow works at least for me.

1 Like

If you check GitHub - ralsina/nicolino: A not-quite-minimalistic SSG written in Crystal it can be switched to markd with a 5 line patch. It’s not done because the last markd release has no tables, no footnotes, etc (I got tables merged into markd, failed with footnotes, but no release ever happened)

(BTW: nicolino is about 30% slower than Hugo, which means it’s pretty damned fast, specially on normal use because it has incremental building)

1 Like

Sorry :sweat_smile: life has been crazy busy for me

1 Like

I know, don’t take that as a complaint :slight_smile:

1 Like

I remembered markd almost release a new version several years ago, but stopped because some reason.

I’ll consider it, guess it depends on whether I want a major project or not. I am curious to see how crystal has changed from way back to now.

Really trying to decide my next Crystal project as I finish wrapping up my first project for the most part aside from random niceties (I also think the next Crystal version may resolve some possible memory leaks since I’m doing XML parsing).

We wanted to fully support GFM, but that came with a lot of edge cases that needed to be fixed

2 Likes

Out of curiosity, are you talking about this?

In case not and if you are using HTTPS connections to read those XML, in an Alpine container, then maybe the memory leak is related to OpenSSL library in Alpine (which is external to Crystal, but there is a solution).

If none of these references are related to your case, please open an issue with the details :slightly_smiling_face: