A Python script that generates HTML code for my personal website by using data from a JSON file, and replacing placeholders in an HTML template.
- Editing the JSON file:
- Make any desired changes under the relevant key in the
webcontent.json
file. - Execute the
main.py
script. index.html
file should generate in the script directory.
- Make any desired changes under the relevant key in the
- Without editing the JSON file:
- Make any desired changes under the relevant key in the
to_json()
function in themain.py
file. - At the very bottom of the
main.py
file, in theif __name__ == "__main__"
statement, remove the comment from theto_json
function call. - Execute the
main.py
script.
- Make any desired changes under the relevant key in the
- Note: The generated JSON and HTML files will work right after they are generated, but are not formatted properly. You can easily format them in a readable format using VS Code by pressing
Shift + Alt + F
(default Windows shortcuts).
I am leaving my personal details in the script and JSON files as an example of the required format. For the assets, scripts and styles files, please visit my personal website repo. Thank you!