home

posts

notes

rss

Using data sources in Hugo

Until now, I have been storing different variables as site parameters in my Hugo website’s hugo.toml file. A regularly triggered GitHub Actions workflow updates these variables by using various APIs to check for any changes. If changes are detected, the workflow updates the hugo.toml file with the new values (replacing the old ones using sed) and pushes the changes to my website’s GitHub repository. There, another GitHub Workflow builds my Hugo website and deploys it to GitHub Pages.

As I start tracking more variables than originally planned, it makes sense to store them the proper way: using data sources in Hugo. My plan is to keep a yaml file in my Hugo website’s data directory, which will store all variables that I want to display on my website. The rest of the workflow should remain unchanged, but this approach should separate these variables from actual site parameters.

running_distance: 720851.2999999999
running_cp: 3.5694862545565007
writing_streak: 12
best_writing_streak: 12
best_writing_streak_date: "2024-08-19"
tr_value: 6150.468645723648
tr_rank: b

I’m planning to write a decent and complete post explaining which APIs I use, the variables that I store (and plan to store in the future), and how these GitHub Workflows work. I currently keep track of the following variables:

VariableValue
Longest writing streak20 days | Achieved on Aug 27, 2024
Current writing streak0 days | Updated on Nov 4, 2024
Running Critical Power3.490 W/kg
Distance ran this year853.6 km
TETR.IO’s TETRA LEAGUE11363.62 TR ()