Repository: getnikola/nikola

Issue:
Easy way to access `CATEGORY_TITLES`/`CATEGORY_DESCRIPTIONS` from `tags.tmpl`
### Discussed in https://github.com/getnikola/nikola/discussions/3583

<div type='discussions-op-text'>

<sup>Originally posted by **kai-tub** November  5, 2021</sup>
Hi :)

Thank you again for providing such a nice static site generator!
I am working on customizing my personal theme and the current goal is to have a _category-based_ landing page.

With `CATEGORY_TITLES`/`CATEGORY_DESCRIPTIONS` I can update the category information into a _prettier_ version.
These variables are then used when the category (index) page itself is rendered.
Now I would like to be able to _re-use_ the information in the `tags.tmpl` page such that I can use the _pretty_ category name as a link with the description to provide extra information.
The category name and description would then be combined into a _card_ with an optional image for easier navigation.

Is there an easy way to accomplish this?
Or am I too stuck on the `tags.tmpl` and should just create a different template and try to use that?


</div>
Easy way to access `CATEGORY_TITLES`/`CATEGORY_DESCRIPTIONS` from `tags.tmpl`
### Discussed in https://github.com/getnikola/nikola/discussions/3583

<div type='discussions-op-text'>

<sup>Originally posted by **kai-tub** November  5, 2021</sup>
Hi :)

Thank you again for providing such a nice static site generator!
I am working on customizing my personal theme and the current goal is to have a _category-based_ landing page.

With `CATEGORY_TITLES`/`CATEGORY_DESCRIPTIONS` I can update the category information into a _prettier_ version.
These variables are then used when the category (index) page itself is rendered.
Now I would like to be able to _re-use_ the information in the `tags.tmpl` page such that I can use the _pretty_ category name as a link with the description to provide extra information.
The category name and description would then be combined into a _card_ with an optional image for easier navigation.

Is there an easy way to accomplish this?
Or am I too stuck on the `tags.tmpl` and should just create a different template and try to use that?


</div>


Discussion:

Resolving patch:
diff --git a/nikola/nikola.py b/nikola/nikola.py
--- a/nikola/nikola.py
+++ b/nikola/nikola.py
@@ -686,6 +686,10 @@ def __init__(self, **config):
                                       'FEED_READ_MORE_LINK',
                                       'INDEXES_TITLE',
                                       'CATEGORY_DESTPATH_NAMES',
+                                      'CATEGORY_TITLES',
+                                      'CATEGORY_DESCRIPTIONS',
+                                      'TAG_TITLES',
+                                      'TAG_DESCRIPTIONS',
                                       'INDEXES_PAGES',
                                       'INDEXES_PRETTY_PAGE_URL',
                                       'THEME_CONFIG',
diff --git a/nikola/plugins/task/categories.py b/nikola/plugins/task/categories.py
--- a/nikola/plugins/task/categories.py
+++ b/nikola/plugins/task/categories.py
@@ -186,6 +186,8 @@ def provide_overview_context_and_uptodate(self, lang):
             "title": self.site.MESSAGES[lang]["Categories"],
             "description": self.site.MESSAGES[lang]["Categories"],
             "pagekind": ["list", "tags_page"],
+            "category_descriptions": self.site.config['CATEGORY_DESCRIPTIONS'](lang),
+            "category_titles": self.site.config['CATEGORY_TITLES'](lang),
         }
         kw.update(context)
         return context, kw
@@ -209,8 +211,8 @@ def provide_context_and_uptodate(self, classification, lang, node=None):
         subcats = [(child.name, self.site.link(self.classification_name, child.classification_name, lang)) for child in children]
         friendly_name = self.get_classification_friendly_name(classification, lang)
         context = {
-            "title": self.site.config['CATEGORY_TITLES'].get(lang, {}).get(classification, self.site.MESSAGES[lang]["Posts about %s"] % friendly_name),
-            "description": self.site.config['CATEGORY_DESCRIPTIONS'].get(lang, {}).get(classification),
+            "title": self.site.config['CATEGORY_TITLES'](lang).get(classification, self.site.MESSAGES[lang]["Posts about %s"] % friendly_name),
+            "description": self.site.config['CATEGORY_DESCRIPTIONS'](lang).get(classification),
             "pagekind": ["tag_page", "index" if self.show_list_as_index else "list"],
             "tag": friendly_name,
             "category": classification,
diff --git a/nikola/plugins/task/tags.py b/nikola/plugins/task/tags.py
--- a/nikola/plugins/task/tags.py
+++ b/nikola/plugins/task/tags.py
@@ -128,6 +128,8 @@ def provide_overview_context_and_uptodate(self, lang):
             "title": self.site.MESSAGES[lang]["Tags"],
             "description": self.site.MESSAGES[lang]["Tags"],
             "pagekind": ["list", "tags_page"],
+            "tag_descriptions": self.site.config['TAG_DESCRIPTIONS'](lang),
+            "tag_titles": self.site.config['TAG_TITLES'](lang),
         }
         kw.update(context)
         return context, kw
@@ -143,8 +145,8 @@ def provide_context_and_uptodate(self, classification, lang, node=None):
             "tag_titles": self.site.config['TAG_TITLES'],
         }
         context = {
-            "title": self.site.config['TAG_TITLES'].get(lang, {}).get(classification, self.site.MESSAGES[lang]["Posts about %s"] % classification),
-            "description": self.site.config['TAG_DESCRIPTIONS'].get(lang, {}).get(classification),
+            "title": self.site.config['TAG_TITLES'](lang).get(classification, self.site.MESSAGES[lang]["Posts about %s"] % classification),
+            "description": self.site.config['TAG_DESCRIPTIONS'](lang).get(classification),
             "pagekind": ["tag_page", "index" if self.show_list_as_index else "list"],
             "tag": classification,
         }


Test patch: