Over the years, I have made several types of blog engines, and sites, and I have never really been happy with anything, but this guide is one of the best attempts so far! Table of Contents I have created my own blog engines with php, cakephp, static with macromedia dreamweaver (if you remember that..), jekyll and even tried to move my blogging to medium.com. But each attempt has left a tangy and bitter taste in my mouth. So, what did I do? I created a new blog engine.. Well, one that I really like! These are the features I required: Knowledge of: Tools: First we need to set up a repository. Head on over to https://github.com and create a new repository. Call it whatever you want, and clone it into your workspace. For the sake of this guide, we are referring to the repository as Then Looks empty, right? Let us proceed. Initialize npm, change the stuff you want with the interactive tool: After you have done that, you will have a directory something like this: After you've done that, install the required dependencies: After you have done that, you will have a directory something like this: Open up your As you can see, we have added some scripts that will build this site: Your If you are like me and love to fine granulate options for the different modules used in this setup, you might want to add some configuration files: To be able to process And it should look something like this: Now, let us add some more folders to this: Remember earlier, from the npm scripts, that we copy over the Go into the In the Then go to the Then in Allrighty then. We've now setup, and ready to write the Create a directory named Open up Now, let us create the template for all of our posts! Create a And it could look something like this: Did you notice the We will cover the post path in the next chapter. We're ready to go! Go into Where Now, open the post in your editor, and add these frontmatter properties: And now you are ready to write your post! Write something down, and we will proceed! Eventually, your Now, we're ready to see it in action. From the root of your project, do this: These commands will build your files, convert your posts and copy your assets, and then open up a browser to view your blog. Since we have not setup an From here you can add posts, add the styling or even JavaScript to your blog. After you have run You have now learned how to build a static blog site! What can be done further? Styling, interactivity, add missing pages and publish on Github Pages!. I will cover more of these features in separate articles. Stay tuned!Features
Prerequisites
Setup
static-blog
;cd
into your project:npm
Dependencies
npm scripts
package.json
, and update the scripts
property to something like this:dist
folder, because you really dont want the produced files in your repositorydist
folderbuild
script, making sure we have assets copied and posts created. (We will come back to the creation of posts)browser-sync
for dev, you can use whatever setup you are used to, but this is what I use.package.json
should look something like this:Configuration files
.browserslistrc
.editorconfig
.postcssrc.cjs
.stylintrc
Rollup
*.styl
files and produced bundled JavaScript, we are using rollup
. Start creating your rollup.config.js
:Folder structure
src/assets/js
assets
folder into dist
? Well, we need a dummy file for the copying of js to work:src/assets/js
directory and create a dummy.js
file:src/assets/css
css
folder, you can put any css file you want, for example a custom styling for prismjs
, or any other library you would use.src/styles
styles
folder to create a index.styl
file, for all your styles.src/main.js
, add the import of your styles, rollup will handle this automatically, converting the *.styl
file into css:/scripts/posts/create.js
file, to be able to convert markdown files to static files!Convert posts
scripts
, and make a file named create.js
inside:create.js
in your editor and add this:The article template
article.html
file in src/assets/templates
:Create a static, sustainable website or blog
, Over the years, I have made several types of blog engines, and sites, and I have never really been happy with anything, but this guide is one of the best attempts so far!
and {{CONTENT}}
strings? We are using them to put the data into it.Create your first post
src/assets/posts
and create your first post:<slug-of-your-post>
is the slug for your post. Don't worry, you can change the file name later.posts
-folder would look something like this:Build and view your first post
index.html
-file, there's nothing to see. However, go to http://localhost:3000/2023/09/30/static-blog.html
and see your first post!npm run build
, the dist
-folder should look something like this:Summary