I am reviewing the build and deployment process of my blog on the server. So here, I will discuss the build script I created to address the issue.
Its purpose is to build a static website using a simple project structure as follows:
project-source-folder/ templates/ header.html footer.html pages/ index.html my-post.html
Simply put, for each html file inside pages/ that is not named “index.html”, eg. “my-post.html”, the script generates a new folder, named the same name as the file name - in this example: my-post/ - then embraces the file content with the header and footer template files - that are defined inside the templates folder - name it "index.html", and puts it inside the created folder as in the image below. All the output generated goes inside an out/ folder that will be later renamed to posts/
project-source-folder/ out/ index.html my-post/ index.html templates/ header.html footer.html pages/ index.html my-post.html
If there is a file named "index.html" inside the pages/ folder, that file will also be embraced by the header and footer templates defined, but no folder will be created to contain it, after processed. As it is the index file, it will be saved in the root of the output folder: in the root of out/ directory.
Example of the final result of the site directory structure deployed:
project-source-folder/ posts/ index.html my-post/ index.html templates/ header.html footer.html pages/ index.html my-post.html
To use the script, you must:
- Set your project as the structure shown earlier
- Call the script, passing in the first parameter, the project folder name (without putting a slash at the end of the folder name):
$ ./dab3x.sh project-source-folder