× Search About Posts Code Music Links
Blank Try
experiment
lots
learn
more

Archetypes with Template Logic

Updated on
Last site update: 8 May 2024

So this page was generated with the following template code at the bottom of the archetypes/code.md file:

1## Latest Code posts
2
3{{ range first 10 ( where .Site.RegularPages "Section" "code" ) }}
4* [{{ .Title }}]({{ .Permalink }})
5{{ end }}

I couldn’t get the spacing of the list items right despite trying with {{- range -}} hyphens.

So it produced a list with gaps:

1* [Testpage](https://blank-try.netlify.app/code/testpage/)
2
3* [Try With Template Logic](https://blank-try.netlify.app/code/try-with-template-logic/)
4
5* [Page Resources](https://blank-try.netlify.app/code/page-resources/)
6
7* [New Image Shortcode](https://blank-try.netlify.app/code/new-image-shortcode/)
8
9// etc.

I’ve deleted these spaces below because they annoy me.

Presumably you could use HTML if HTML is allowed in the config OR perhaps simply call a shortcode in.

The docs warn:

the site will only be built if the .Site is in use in the archetype file, and this can be time consuming for big sites.

Hugo docs

Latest Code posts