You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
If you use Templater together with the Periodic Notes plugin for weekly notes, there is a locale-dependent token mismatch that causes your filename and note content to disagree on the week number. This is easy to hit if you try to use ISO week tokens (GGGG, WW) in your weekly note format.
The problem
Periodic Notes generates the filename by calling moment().startOf("week") before formatting. In a US locale (Sunday-start), this snaps Monday back to the previous Sunday. If your template then uses ISO week tokens (GGGG, WW) to display the week number, Templater will show a different (correct) week number because Templater processes the template at file-creation time without the startOf("week") step.
Example on Monday April 27, 2026 (US locale):
What generates it
Token
Result
Periodic Notes (filename)
YYYY-[W]WW applied to Sunday April 26
2026-W17 ❌
Templater (content)
tp.date.now("WW") on Monday April 27
18 ✅
The filename says W17, the content says W18. Extremely confusing to diagnose.
The fix
Use locale week tokens throughout: gggg instead of GGGG, and ww instead of WW. In a Sunday-start locale, gggg-[W]ww applied to Sunday April 26 gives 2026-W18 — agreeing with Templater's output for Monday April 27.
In your Templater weekly template, use:
<%*constisoDay=parseInt(tp.date.now("E"));// 1=Mon, 7=SunconstdaysToMonday=1-isoDay;// Anchor weekNum and year to Monday so the note is correct// regardless of what day of the week you open itconstweekNum=tp.date.now("ww",daysToMonday);constyear=tp.date.now("gggg",daysToMonday);constprevWeek=tp.date.now("gggg-[W]ww",-7);constnextWeek=tp.date.now("gggg-[W]ww",7);-%>
Anchoring weekNum and year to Monday (via daysToMonday) is also important — without it, if you open the note on Sunday before midnight, ww will return the previous locale week's number.
And in periodic-notes/data.json (or the Periodic Notes plugin settings UI), set:
Weekly note format: gggg-[W]ww
Who this affects
Anyone in a US/Sunday-start locale using ISO week tokens in their weekly note template combined with the Periodic Notes plugin. This is likely a large portion of US-based users of both plugins.
Root cause (for the curious)
The Periodic Notes plugin calls date.clone().startOf("week") before formatting the filename. startOf("week") and gggg/ww tokens both use the same locale definition of week boundaries. ISO tokens (GGGG/WW) use a fixed Monday-start definition regardless of locale — which diverges from startOf("week") whenever the locale week doesn't start on Monday.
This discussion was converted from issue #1720 on April 29, 2026 01:39.
Heading
Bold
Italic
Quote
Code
Link
Numbered list
Unordered list
Task list
Attach files
Mention
Reference
Menu
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
Context
If you use Templater together with the Periodic Notes plugin for weekly notes, there is a locale-dependent token mismatch that causes your filename and note content to disagree on the week number. This is easy to hit if you try to use ISO week tokens (
GGGG,WW) in your weekly note format.The problem
Periodic Notes generates the filename by calling
moment().startOf("week")before formatting. In a US locale (Sunday-start), this snaps Monday back to the previous Sunday. If your template then uses ISO week tokens (GGGG,WW) to display the week number, Templater will show a different (correct) week number because Templater processes the template at file-creation time without thestartOf("week")step.Example on Monday April 27, 2026 (US locale):
YYYY-[W]WWapplied to Sunday April 262026-W17❌tp.date.now("WW")on Monday April 2718✅The filename says W17, the content says W18. Extremely confusing to diagnose.
The fix
Use locale week tokens throughout:
gggginstead ofGGGG, andwwinstead ofWW. In a Sunday-start locale,gggg-[W]wwapplied to Sunday April 26 gives2026-W18— agreeing with Templater's output for Monday April 27.In your Templater weekly template, use:
Anchoring
weekNumandyearto Monday (viadaysToMonday) is also important — without it, if you open the note on Sunday before midnight,wwwill return the previous locale week's number.And in
periodic-notes/data.json(or the Periodic Notes plugin settings UI), set:Who this affects
Anyone in a US/Sunday-start locale using ISO week tokens in their weekly note template combined with the Periodic Notes plugin. This is likely a large portion of US-based users of both plugins.
Root cause (for the curious)
The Periodic Notes plugin calls
date.clone().startOf("week")before formatting the filename.startOf("week")andgggg/wwtokens both use the same locale definition of week boundaries. ISO tokens (GGGG/WW) use a fixed Monday-start definition regardless of locale — which diverges fromstartOf("week")whenever the locale week doesn't start on Monday.All reactions