Is it possible to have a content type build last?

I am building a Site.Home.Scratch with all the links in the render link template and want to access the full list in a separate layout to build a json file with them.

Is it possible to build that layout after the others have finished or is there a better way to get the full list of links?

No. This capability is most frequently associated with a desire to display backlinks. Perhaps this will be possible at some point with a defer keyword/function/method.

Here’s one approach, from topic #33328:

  1. In your render hook, add data attributes to the anchor element indicating source of link (data-permalink, data-title, etc.)
  2. Build the site.
  3. Use an external script to parse (using xmllint or similar) HTML files in the publish directory, and build a JSON database of links.

My memory about this may be a little hazy, but in Hugo’s render method there are two entities that is serialized (and not parallelized) and have a deterministic order:

  • Site (aka language)
  • Output format

all output formats for a site is the union of all output formats set in config and front matter, ordered by weight (and then name). So, if you create a output format with a large weight value and then create a template for that for, say, the home page – that will pretty much be the last thing to be done.

2 Likes

I just changed the output to json and it did exactly what i needed. Many thanks

@bep, Great to know. Where/how to define the output format weight?

2 Likes

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.