Hello fellow Obsidians,
I’ve recently started to go to the gym and wanted to journal my gym workouts.
Also, I wanted to make a template for each variation of my workout, with checkboxes so that I can keep track while working out of what I’ve done and what’s left to do.
I’ve stumbled accross a blogpost with a solid base that I wanted to expand upon. Unfortunately I can’t include the link for reference, but you would find it with a quick research for:
Workout Log in Obsidian I Josh
So, to make it simple, I have:
- three files, called J1_Template, J2_Template and J3_Template.md, one for each of the weekly variations of my workout;
- a file with all my exercise informations (weights, reps, series, rests, etc.);
- a file called LaunchWorkout.md that has 3 buttons, one for each of the 3 variations of my workout.
When I click on one of these buttons, templater creates a new file based on that specific template and saves it in a custom folder where I have my jounaling stored. Here’s the J1 button code:
style: primary
label: J1
actions:
- type: templaterCreateNote
folderPath: "Journaling/Workout"
templateFile: "Journaling/Templates/D1_Template.md"
openNote: true
A prompt appears and suggests today’s date as a name, and then templater appends the variation selected to rename the file. Here’s the code for that:
// Prompt the user for the date, defaulting to today
let date = await tp.system.prompt("Date?", tp.date.now("YYYY-MM-DD"));
// rename the file using today's date and the selected workout type
await tp.file.rename(date + " - D1 Workout");
What I’m trying to do
So, what I would like to achieve, is that the files get stored using the date.
Let’s say that I created a file today, July the 4th. I would like that file to be saved like this:
Journaling/Workout/2026/07 - July/2026-07-04 - D1 Workout.md
Things I have tried
So far, I tried using this as the default prompt:
// Prompt the user for the date, defaulting to today
let date = await tp.system.prompt("Date?", tp.date.now("YYYY/MM - MMMM/YYYY-MM-DD"));
but templater returns an error: filenames cannot contain slashes.
That means I have to find a way to check that the year and month folder already exist, and then maybe MOVE the created file to the right folder. But I’m not sure how to do that. (I’m also pondering adding a button to my templates that stores the file conveniently, that I could press once the session is finished or the data is reviewed or whatever)
Also, I have an unexpected behavior that I would like to address (this is very minor, but since I’m here)
In my template, I have this:
<%* for (const exerciseKey in exercises) { _%>
- <% exercises[exerciseKey] %> :
<%* if (weight[exerciseKey] != "Bodyweight") { _%>
- [ ] **Warmup :** <% reps[exerciseKey] %> reps with <% warmupWeight[exerciseKey] %>k
<%* } _%>
- [ ] **Workout :** <% series[exerciseKey] %> series of <% reps[exerciseKey] %> reps with <% weight[exerciseKey] %>k – rest: <% rests[exerciseKey] %>s
<%* for (let i = 0;i < series[exerciseKey]; i++) { _%>
- [ ] <% i+1 %>
<%* } _%>
<%* } _%>
Gets me that result:
As you can see, the next iteration of the first for loop is indented, and I don’t know how to put it back to the far left of the document, same as the previous exercise. Any ideas?
