I started by building a static site as a small side project for my brother—but then I wanted partials... and regression tests. I thought partials w...
For further actions, you may consider blocking this person and/or reporting abuse
I like this approach because, even though you're most likely reinventing the wheel, you often learn new stuff along the road and learning is the most important thing in our industry. Hats off to you.
😊
I agree about keeping dependencies low in small projects! When I hop between multiple projects, I can feel the context switching cost if there are setups involved.
By the way, this looks like a great use-case for…
I haven’t used PHP in years... and this seems very appealing!
What stack do you primarily use? Thanks for your response beforehand.
Blasphemy! Beautiful blasphemy!
BlasPHPemy!
That’s awesome!!! 👏
I’ve been there too, I once was tinkering with markdown parsing when I built this small library (link below) and it turned out that the live demo I made of using it could be seen as a somewhat static site generator from markdown files
I also felt kinda silly initially but now I want to revisit it as it was kinda fun too (and also try building a dependency free one from scratch like yours)
this-fifo / use-marked-hook
A react hook for parsing markdown with marked and sanitize-html
useMarked() hook
Live Demo
The app located at
/example
demonstrates how it could be used, see the live result at this-fifo.github.io/use-marked-hook/Install
Usage
License
MIT © Filipe Herculano
Neat!
I had built a simple static site generator back before CMSs were a thing and SSGs had a name for themselves. I believe in those days everyone working on web development had something similar for organizing site development right ?
v2 of my personal website was templated using Apache Velocity and some home-brew wrapper code to pick up resources from disk... I thought that was a silly idea back in about '05 and replaced it with a MoinMoin wiki. Now I'm back to Hugo :-/
This is mine. I decided to use erb since its not really much different than using handlebars.
Best part is if you don't use any ruby's gems other than standard easy to put on a lambda and use CodeBuild and CodePipeline to automatically deploy changes to S3 Static Website Hosting.
For my use case I have to compile at least a thousand pages and doing it this way is under a 1 minute
I had built one from scratch as well. Mine is mainly used for minimizing page size and optimizing page rendering, hot-reloading is included for development.
The code above is about 3 years old, feel free to run it at your own risk.
Lol I love that we're greeted with a
:shrug:
banner as we open the article.Also, yeah, if you have time to build an interesting side project while building a side project, go for it. If I'm reaching for a static site generator, I like to use Nuxt at the moment—although I'm already partial to Vue and I haven't done anything crazy with it yet.
Cool learning exercise. Have you checked out Svelte? It’s got a similar tooling stack to react and angular but imho much lighter weight and less quirky you can definitely build static sites with it.
Just throwing it out there. Hope you’re doing well Ben.
svelte.dev/
That's how I wound up with my current site. In late 2014 I was using Octopress, which was fine, but I don't really use Ruby professionally and so I thought ideally I'd be using a Node.js solution. On a whim I rolled a very simple proof of concept for a Grunt plugin to convert Markdown and Handlebars templates into HTML, and put together a Yeoman generator to set it up with some other plugins. It went so well that in early 2015 I switched over to it and have been using it since, though lately I have been considering switching to Gatsby.
Same here I also made two of the static site generators both are featured on staticgen.
Python based : my_py_site
github.com/sharadcodes/my_py_site
C++ based: sudo_site
github.com/sharadcodes/sudo_site
my_py_site is capable of doing more then rendering templates, it is able to generate multiple blogs without configuration and it also parses and separates the YML front matter and the Markdown content converted to HTML. You can access that YML front matter anywhere in the templates and moreover the Meta data of pages and posts is also accessible in the templates.
You can use different layouts for any post or page as well. Just specify layout in YML front matter.
All is done under 100 lines of code
Could you abbreviate it to
bi.rb
? For the memes?I can totally understand that you did it, as I did the same few months ago and I still like to take some holidays from the nowadays generators like Gatsby, NextJS, Hugo etc. and build my own thing.
I don't expect that this becomes popular or something. It just fits my purpose and helps me learning new things along the development road.
andi1984.dev/posts/my-static-site-...
The advantage is that you only get what you need, no less no more, minimal overhead (both mental and memory/cpu/LOC).
The disadvantage is that, when you find out that you need more, you'll run into limitations, and at that point you'll have to decide - add more features (and risk losing the charm & the simplicity), or migrate to a "real" SSG.
But if you know that your requirements will stay simple then it may be a good choice!
Can you explain what you mean by “partial”. I mean, I see the files named .partial.* but what do want achieve with that?
Re-usability, for the most part. You don't want to just copy paste the same exact code in every page. You make a partial, for example, that damned footer you want to put in the same page - now you don't have to copy & paste manually all the time. Just add an include to it.
Another thing - change something in the partial file -> it reflects everywhere you do it. You don't want to hunt down that exact code in every damn page.
and here I am planning to get started with a markdown to html parser
If you have fun reinventing the wheel, everything else is irrelevant.
We sometimes forget that, in our everything-needs-to-be-productive-and-useful mind 😊
Did the same thing... but in C, in 2018.
It's good to realize a static site generator only concatenate some files into some other files, it's really this simple.
Well that's another static site generator, I can't resist to try...
My personal site has its own sort of static generator. It started very simple (a script to run some templates) but has become more complicated over time.
I wrote the same SSG twice; once in Perl, once in Python: tumblelog. You can see it in action here: Plurrrr.