Using Markdown to Represent Blog Posts
October 16 2023 - 2 Minutes - Source
meta - python

this is an image of my first blog post behind the scenes
Hello! I have decided to explain how this blog works. This blog uses markdown which is used for formating + metadata for blog posts.
Simple Explanation
This section is just a simple explanation for my blog, for a more advanced explanation scroll down.
Every single one of my blog post's are stored in a blog folder in the root of my flask project.
Every markdown files name is just a number, for example my first blog post's file name was 1.md and this blog post's file name is 2.md this sets the id for the blog post.
Everyone of the markdown files have metadata at the top of the file.
This metadata includes:
- TITLE, this title is used for the heading and the title of the tab for the post.
- SOURCE, this is the
hreffor the source link at the top of the posts. - DATE, this is a string that has the date that I wrote the post, I could theoretically set the date to anything.
Advanced Explanation
My code simply reads the first 3 lines of the markdown file, and then caches it so that in the future no file operations need to occur.
This caching of the data speeds up the response by a lot.
However it means that I need to restart the the server to clear the cache while I write these blog posts.
Conclusion
The way I represent blog posts has advantages and disadvantages, it is quick but it does not allow for comments or likes.
A reason I did it like this wo/ a database is that I felt that this should be a simple project and needing a database would make this simple project overcomplicated.
Thank you for reading! I hope you found it informative!