DEV Community

Cover image for I built my own static site generator.

I built my own static site generator.

Roshan Acharya on July 22, 2020

Hi everyone, I'm writing my first article on dev.to and it's about the static site generator I have been building. About a month ago, I saw a webs...
Collapse
 
bias profile image
Tobias Nickel

cool, When I was last time refactoring my website, I also checked a bunch of SSG's. ended up with hexo.js, because I wanted one in node.js.

but it has bad error logging and when building it can be hard to find the corrupted file in my source.

it's code has for my taste actually to many unnecessary abstractions. what is making debugging hard. but it was always good enough that I don't start over. I also managed to make a plugin for it. But it's APIs made it more difficult than needed.

I did not know the VM module, will definitely check? it out. Once a colleague needed a template engine, So I wrote him this code:

function render(template,  data) {
  return template.split('{{').map((part, i)=>{
    if(!i) return part;
    const [key, rest] = part.split('}}') ;
    return data[key] + rest;
  }).join('');
}
console.log(render('Hallo {{name}}!! ', {name:'Tobias'})) 
Enter fullscreen mode Exit fullscreen mode

Still advising to use underscore template,...

thanks for this post, I will check out your project.

Collapse
 
coderosh profile image
Roshan Acharya

Thank you Tobias Nickel for sharing your experience with SSG. SSG I built also doesn't have a good error logging, but I'm working on it. Never used underscore template. I will check surely check that out.

And also thank you for that code.🥰

Collapse
 
sauravgautam320 profile image
sauravgautam320

wow i tried it out...no words, its like a simplified version of all other SSG. So easy to use.
loved it.

Collapse
 
coderosh profile image
Roshan Acharya

Thank you sauravgautam320 for your kind words. This type of reviews really inspires and motivates me to not give in to the stress, mind boggling moments and sudden urge to smash the keyboard [ LOL ] while coding. This kind of review really nullifies all the stress and anxiety I went through while working on this project. Thank you again, keep supporting. thank you ❤️.

Collapse
 
sagarka13694337 profile image
sagarkarki076@gmail.com

Wow, cool.
I checked that out and it's so much easier to setup than other SSG.

Collapse
 
coderosh profile image
Roshan Acharya

Thank you sagar karki. It was so nice of you to say so. ♥️

Collapse
 
shadowtime2000 profile image
shadowtime2000

Extremely cool! Is there any specific usage for ulka?

Collapse
 
coderosh profile image
Roshan Acharya

Thank you shadowtime2000. For now, I can't exactly point out the specific usage. I am still working on it.

Collapse
 
rajeevpaudel profile image
rajeevpaudel

i was also intrested in ssg and was thinking about building one. It is a good reference project to look on.

Collapse
 
coderosh profile image
Roshan Acharya

Thank you mate. Good luck ♥️

Collapse
 
johnbokma profile image
John Bokma

Building an SSG is a great exercise. I had specific requirements so I made tumblelog: github.com/john-bokma/tumblelog. I use it for my (mostly) link blog plurrrr.com/.