Hello,
I have discovered an inconsistency with the behavior of the special placeholder :counter
in name
/ title
parameters in the resources
front-matter.
Problem
If a Resource file is “fetched” by one set of resources
→ src
rule, and then again using a different resources
→ src
rule later, :counter
value substituted in name
(probably in title
too) stays stuck at 1.
The above problem statement might not make sense at first read, so please review the below details.
Details
What works
This scenario works as expected i.e. the :counter
is doing expected substitutions in the Resource Name.
Here I have only:
[[resources]]
src = "**.pdf"
name = "pdf-file-:counter"
-
Test file “Resource Counters A” Hugo output (Markdown source linked within that test page)
- Scroll down to Resources (Debug) section on that page for
.Resources
debug info.
- Scroll down to Resources (Debug) section on that page for
Counter in name
increments fine.
What doesn’t work
In this scenario, the Resource that is “fetched” twice (i.e. photo_specs.pdf) has its counter stuck at 1.
Here I have:
[[resources]]
src = "documents/photo_specs.pdf"
title = "Photo Specifications"
[[resources]]
src = "**.pdf"
name = "pdf-file-:counter"
-
Test file “Resource Counters C” Hugo output (Markdown source linked within that test page)
- Scroll down to Resources (Debug) section on that page for
.Resources
debug info.
- Scroll down to Resources (Debug) section on that page for
The difference from the “What works” case is that, here I first set the title
for "documents/photo_specs.pdf"
.
The behavior is strange though… it could be understood if the name
rule had no effect on the Name
of "documents/photo_specs.pdf"
… assuming that Name was set implicitly in the first rule. The problem is that the Name
does get almost set as per the name
rule but the count is always stuck at 1.
In summary, if a resource is fetched by an src
filter earlier, the :counter
messes up if set in a later rule.
Or, to put it another way — It seems like :counter
can be used only in the set of rules that first “fetches” a resources.
I hope all that made sense… It was a bit complicated to explain the issue.