first post of this blog. I’m not sure if that’s the official first. But it’s the oldest I have on record.
I’ve notice that my blogging slows down a little more every year. Life and work get in the way. Sitting down to write a blog takes time and I have less of that as each day passes.
Today, you are as old as you’ve ever been, and as young as you ever will be.
At first, the blog was just my way of keeping track of problems I’ve encountered along the way and how to solve them. I very clearly remember solving a problem and recalling that I had the exact same problem a year earlier, but forgot the solution. Hence, the birth of this journal. I’m mostly writing for me. You can see along the way the advice has slowly changed, and the posts a little more thoughtful.
/pages
folder and had to be organized how you wanted to route them./year/month/day/slug
I was using with Hugo.git clone [email protected]:gndx/ev0-astro-theme.git
, then cd ev0-astro-theme
, npm install
, npm run dev
and start working.hugo
, which for me was in the content/post
folder. I moved the entire post
folder to its own location so I could go through it and fix things.I was using the directory per post approach of Hugo, so each post looked like this structure
🔻 📂 a-better-password-reset-token
🔻 📂 images
📄 old-thumbnail.jpg
📄 thumbnail.jpg
📄 index.md
This is the command I ran a few times while I was tweaking the ETL1
rm ./content && # remove the existing folder
mkdir content && # recreate the folder
cp -a ./hugo/content/post/* ./content && # copy the content from Hugo to this upper folder
mkdir content/NEWFILES/ && # This is the folder that holds the converted Markdown files
touch content/NEWFILES/index.md && # This was needed so the script didn't blow up
python3 convert-subs.py && # Convert subdirectory
rm content/NEWFILES/newfiles.md && # file created by one of the scripts, just remove it, it causes issues with Astro
python3 convert-front-matter.py && # Convert some frontmatter dates and descriptions
cp -r ./content/NEWFILES/* ./ev0-astro-theme/src/content/blog/ # copy the converted files into Astro
Here are some of the python scripts used above, YMMV
# convert-subs.py
import os
def convert_subdirectories_to_files(directory_path):
for root, dirs, files in os.walk(directory_path, topdown=True):
for dir_name in dirs:
print(dir_name)
# Form the old directory path and the new file name
old_dir_path = os.path.join(root, dir_name)
new_file_name = dir_name.lower() + ".md"
# Form the new file path by joining the root directory with the new file name
new_file_path = os.path.join(root, 'NEWFILES', new_file_name)
# Rename the index.md file to the new file path
os.rename(os.path.join(old_dir_path, "index.md"), new_file_path)
# Remove the now empty old directory
# os.rmdir(old_dir_path)
break
# Usage:
convert_subdirectories_to_files('./content')
# convert-front-matter.py
# Need to run `pip3 install python-frontmatter`
import frontmatter
from datetime import datetime
import os
def process_markdown_file(file_path):
# with open(file_path, 'r') as file:
# content = file.read()
post = frontmatter.load(file_path)
# Access and modify the desired frontmatter properties as needed
if post['date'] and type(post['date']) == str:
post['pubDate'] = datetime.fromisoformat(post['date']).isoformat()
else:
post['pubDate'] = post['date'].isoformat()
post['description'] = post['title']
# if hasattr(post, 'tags'):
# post['tags'] = post['tags']
# else:
# post['tags'] = []
new_content = frontmatter.dumps(post)
# print(new_content)
with open(file_path, 'w') as file:
file.write(new_content)
def convert_properties_in_markdown_files(directory_path):
for root, dirs, files in os.walk(directory_path):
for file in files:
if file.endswith('.md'):
file_path = os.path.join(root, file)
process_markdown_file(file_path)
# Usage:
convert_properties_in_markdown_files('./content/NEWFILES')
Sorry, I don’t have any good advice here. I just brute force added the images for the post covers. I still have a whole bunch of broken images I need to fix, but that will come in time.
I had a short code for embedding YouTube videos, but with just sticking with Markdown, I found this handy little suggestion for linking to YouTube videos. It will grab the thumbnail for the video and link to the video. Nice.
[![The Last Lecture](https://img.youtube.com/vi/j7zzQpvoYcQ/0.jpg)](https://www.youtube.com/watch?v=j7zzQpvoYcQ)
If I haven’t migrated away to a different publishing platform, you can see the code for this blog on GitLab. Now I’m using GitLab pages to publish the post (cached by CloudFlare). You could use CloudFlare to host or even Netlify. All good options in their own right.
1 Extract. Transform. Load.