Matrix view of all pages + translations (Draft screenshot attached)

I’m trying to figure out a way to view all pages within a matrix that shows the path + if the page is translated. Does anyone have any ideas how to get there? Any suggestion is highly appreciated!

Something like this:

some ideas to start - NOT tested!!!

{{ range .Site.RegularPages }}  # where lang = en ???
{{ $en := .File }}
{{ $de :=  relref path=$en lang="de" }}
{{ $fr :=   relref path=$en lang="fr" }}
# build the table ...

{{ with $de }} Yes {{else}} No {{end}}
# etc

{{ end}}

Totally from memory and untested:

{{ $table := slice }}
{{ range .Site.Pages }}

{{ $p := . }}
{{ $entries := slice }}
{{ range $.Site.Languages }}

{{ $translated := false }}
{{ range $.AllTranslations }}
{{ if eq .Lang $p.Lang }}
{{ $translated = true }}
{{ end }}
{{ end }}

{{ $entries = $entries | append (dict .Lang  $translated) }}
{{ end }}
{{ $table = $table | append (dict "path"  $p.RelPermalink "entries" $entries) }}

{{ end }}

The above isn’t super-effective, but was the simplest I could think of.

it’s a missing feature for multi lang sites :wink:
Add a option for hugo to generate a csv file??

In Hugo v0.56.0+

hugo list all

produces a CSV file with this info:

path,slug,title,date,expiryDate,publishDate,draft,permalink

Maybe a future hugo list all could include translation info?!

If you use Asciidoc(tor), you can do something like this to nicely display the CSV info:

[%header,format=csv]
|===
include::{localincludedir}/hugo-list-all.csv[]
|===

That’s what I have in one of my always-draft Hugo .adoc content files.

1 Like