Extending tagging helper

8 views
Skip to first unread message

S. Qiouyi Lu

unread,
Oct 4, 2026, 1:19:12 PM (12 days ago) Oct 4
to nanoc
Hi, I'm back!

I noticed as I'm adding more pages that my tag index pages are working as I expected (i.e., only updating if a new entry has been added that includes the tag), but my wrestler pages are not working as expected (i.e., every wrestler page updates whenever I add a new match regardless of whether the wrestler is in it or not). This seems to be slowing down compilation significantly, and it's only going to get worse as I add more pages.

I think the difference is that the tags pages are using the tagging helper, which seems to use @items.select, whereas my wrestler index pages are using @items.find_all.

I wanted to basically copy the Tagging helper, but adapt it so that it handles the metadata structure I have, which is:

wrestlers:
  - name: NAME
    slug: SLUG
  - name: NAME
    slug: SLUG

which means using the mapping structure as discussed in my previous "Generate tag pages" thread.

However, I can't quite seem to figure out how to adjust the code. Any guidance would be appreciated. Please let me know if you need any additional code snippets for this to make more sense.

Thanks so much,
S.

Denis Defreyne

unread,
Oct 5, 2026, 7:23:27 AM (11 days ago) Oct 5
to na...@googlegroups.com
Hi S,

There is a feature in Nanoc that’s still behind a feature flag that might help you here: the #where method on collections. Like #select, it can be used to find items by attribute, like this:

@items.where(kind: 'article')
@items.where(kind: 'article', year: 2020)

You’ll need to set the environment variable NANOC_FEATURES to where, e.g.

export NANOC_FEATURES=where

The primary advantage to using #where over #select is that it generates only very specific dependencies. As a result, you’ll find that Nanoc will recompile fewer pages.

If you combine this with a preprocess block that sets the item types, then you’d be able to efficiently find individual wrestlers, like this:

# in Rules
preprocess do
  @items.find_all('/wrestlers/*.md').each do |w|
    w[:kind] = 'wrestler'
  end
end

# elsewhere
@items.find(kind: 'wrestler', slug: 'abc')

I’m not certain that this fits the structure of the data in your site as you have it right now. Let me know what you think!

--
---
You received this message because you are subscribed to the Google Groups "nanoc" group.
To unsubscribe from this group and stop receiving emails from it, send an email to nanoc+un...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages