I have the following content structure:
content/
├─ dsa/
│ ├─ q1.org
│ ├─ q2.org
q1.org has the following contents:
#+TITLE: Lorem ipsum dolor sit amet
#+TAGS[]: string dp done
q2.org has the following contents:
#+TITLE: Lorem ipsum dolor sit amet
#+TAGS[]: array dp backtracking
etc
I have created a list page for listing these pages, but I’d like to combine them under same tags. For example:
Array
Q1_title array
dp
Q2_title array
DP
Q1_title array
dp
Q4_title dp
LL
Q3_title ll
… and so on.
I found GroupByParam
and other groub by functions, but could not get it to work on tags.
I need to list tags only under this section, there are other tags in the site which I do not want listed here.
Is this possible natively? Even hacky solutions are welcome
Have a look at the .Site.Taxonomies
collection.
Here’s an example, the ellipsis denoting the existence of many more .Page
properties:
.Site.Taxonomies
{
"categories": {
"category-a": [
{
"Weight": 0,
"Page": {
"RelPermalink": "/post/post-01/",
"Title": "Post 01",
"Section": "post"
...
}
},
{
"Weight": 0,
"Page": {
"RelPermalink": "/article/article-4/",
"Title": "Article 4",
"Section": "article"
...
}
}
],
"category-b": [
{
"Weight": 0,
"Page": {
"RelPermalink": "/post/post-01/",
"Title": "Post 01",
"Section": "post"
...
}
},
{
"Weight": 0,
"Page": {
"RelPermalink": "/article/article-2/",
"Title": "Article 2",
"Section": "article"
...
}
}
]
},
"tags": {
"tag-a": [
{
"Weight": 0,
"Page": {
"RelPermalink": "/post/post-01/",
"Title": "Post 01",
"Section": "post"
...
}
},
{
"Weight": 0,
"Page": {
"RelPermalink": "/article/article-2/",
"Title": "Article 2",
"Section": "article"
...
}
}
],
"tag-b": [
{
"Weight": 0,
"Page": {
"RelPermalink": "/post/post-01/",
"Title": "Post 01",
"Section": "post"
...
}
},
{
"Weight": 0,
"Page": {
"RelPermalink": "/article/article-2/",
"Title": "Article 2",
"Section": "article"
...
}
}
]
}
}
We want to select the “tags” taxonomy, range through the terms, and within each term range through the weighted pages that exist in a given section.
For example:
{{ $taxonomy := "tags" }}
{{ $section := "post" }}
{{ range $term, $weightedPages := index site.Taxonomies $taxonomy }}
{{ $termPage := site.GetPage (printf "%s/%s" $taxonomy $term) }}
<h2>
<a href="{{ $termPage.RelPermalink }}">{{ $termPage.LinkTitle }}</a>
</h2>
<ul>
{{ range where $weightedPages "Page.Section" $section }}
<li>
<a href="{{ .RelPermalink }}">{{ .LinkTitle }}</a>
</li>
{{ end }}
</ul>
{{ end }}
Hi! Thank you for the reply. I had looked at this earlier, but I don’t want this.
I want something like this:
Tag 1
- some post of tag 1
- another post of tag 1
Tag 2
- some post of tag 2
- some post of tag 1 (post had both tag 1 and tag 2)
…
I do not want to list all tags from the site, just the ones in the current section.
Thank you!
That is exactly what this does.