DEV Community

Cover image for Octo: The Open Source Static Site Generator
Luigi Zaccagnini
Luigi Zaccagnini

Posted on

Octo: The Open Source Static Site Generator

After my first blog post I decided what was a better way to start into open source then building my own open source project! I then built a static site generator in Javascript called Octo. The project was created with the idea of shipping a finished product is better than shipping when the product is perfect. This is important because if I shipped a perfect product, I would not be writing this post and most likely would still be writing code for an infinite amount of time.

What is a Static Site Generator?

A SSG(static site generator) is a tool that creates static HTML pages based off of a template or some raw data provided. Octo is designed to only accept .txt files and create static html documents based off of the content within the text files. Octo will read the text data and make paragraph elements every time there is a space between content.

Tool Setup

Installation

This builds Octo so you can access it anywhere on your computer using the octo command.

  • Clone the repository
  • cd into the folder
  • run npm i to install all dependencies
  • run npm install -g .

Features

Input

The -i or --input flag means the input path. This will look for all texts files with the given path. You can give a .txt file as input or a directory. This is a required field for the program to work. Any files/directories with spaces should be entered with quotes:

octo -i "Sherlock Holmes Selected Stories/test.txt"
Only text files work with this program.

Examples

File Input

This will take the content from the text file and output a HTML file.

    octo -i test.txt
Directory Input

This will go though a directory named test and look for all nested .txt files.

    octo -i test

Output

The output allows the user to specify the path where the files/directories can be exported.
This is not a required field and will default to './dist' if no option is given.

Examples

The -o or --output flag means the output path. This will create a folder called htmlFiles outside of the current directory.

    octo -i test.txt -o ../hmtlFiles

Recursive File Searching

If a input is a directory, Octo will recursively go through all the child directories and convert all the text files into HTML.

Conclusion

After creating my own open source project, I was able to grow as a software developer! Although it may seem to be not as difficult of a task, the few things that were difficult for me were:

  • Publishing my code online for everyone to see
  • Submitting code that could possibly be buggy
  • Not having a 100% completed software

Those thoughts might have made it difficult at first but, I was able to move past this and understand that these things are okay! Comment some features that you would like to see with this project, I would love to add them to the Github repository. I am also excited to get pull requests from people in the community to help make this tool better! If you want to contribute to the project or check out the link to the sample site, the links will be under here!

Top comments (6)

Collapse
 
johnbokma profile image
John Bokma

Congratulations on joining the club! I also wrote a SSG called tumblelog. I use it for my blog Plurrrr. Actually I wrote two versions, one in Perl and one in Python. Each version consumes a single file with articles in Markdown.

Collapse
 
pandademic profile image
Pandademic

nice! try using liquid tags for the repo.

Collapse
 
luigizaccagnini profile image
Luigi Zaccagnini

Will write the issue on the repo! Thank you for the recommendation!

Collapse
 
pandademic profile image
Pandademic

No problem!

Collapse
 
ricksegal profile image
Rick Segal • Edited

Congrats on the accomplishment! Let the adventures continue! Greetings from the other side here on Vancouver Island.

Collapse
 
luigizaccagnini profile image
Luigi Zaccagnini

Thank you!