diff options
author | Parsia Hakimian <parsiya@users.noreply.github.com> | 2016-08-25 08:25:50 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2016-08-25 08:25:50 +0300 |
commit | f843be89e1dca6238269b571573a05fa0ecc24ad (patch) | |
tree | 8eeff50668d53901eab55dccb0758b4c2eadcf01 | |
parent | 00f303b393fd3a3a615065b52c7e241067dce598 (diff) | |
parent | dcd9aadd0a9359740d508f3c41d659f9dd5ac071 (diff) |
Merge pull request #22 from parsiya/taxonomoy-stats-issue-21
Add taxonomy page functionality. Fixes #21
-rw-r--r-- | README.md | 14 | ||||
-rw-r--r-- | layouts/_default/terms.html | 40 | ||||
-rw-r--r-- | sample-config.toml | 14 |
3 files changed, 64 insertions, 4 deletions
@@ -20,6 +20,7 @@ Hugo-Octopress is a port of the classic [Octopress][octopress-link] theme to [Hu - [License page](#licensepage) - [Table of contents](#tableofcontents) - [Not Found or 404.html](#notfound) +- [Taxonomy pages](#taxonomy) - [Issues/TODO](#issues) - [Attribution](#attribution) - [Ported by](#portedby) @@ -364,6 +365,19 @@ There are two optional parameters in the config file and both support markdown: If they are not set in the config file, a default page is generated. +## <a name="taxonomy"></a>Taxonomy pages +The theme can create pages that list all taxonomies (categories and tags) and their count. The taxonomy pages are at `baseURL/tags/` and `baseURL/categories`. This can be accomplished by adding `generateTaxonomyList = true` to the config file. By default the theme sorts the items by count. It can be changed to alphabetical by including `sortTaxonomyAlphabetical = true`. + +The switches are as follows: + + [Params] + generateTaxonomyList = true + + # This is not needed unless alphabetical sort is needed + # sortTaxonomyAlphabetical = true + +To revert back to ByCount sort, remove `sortTaxonomyAlphabetical` or set it to false. + ## <a name="issues"></a>Issues/TODO If you see any issues/bugs or you are looking for some features please use the Github issue tracker. Please keep in my mind that my day job is not development and I may be slow in fixing things (or I may ask you to help me with it). diff --git a/layouts/_default/terms.html b/layouts/_default/terms.html new file mode 100644 index 0000000..a3b6927 --- /dev/null +++ b/layouts/_default/terms.html @@ -0,0 +1,40 @@ +<!-- Template for /tags/ and /categories/ --> + +{{ $page := . }} +{{ $data := .Data }} +{{ $.Scratch.Set "terms" $data.Terms.ByCount }} <!-- default is ByCount --> + +{{ with .Site.Params.generateTaxonomyList }} + + {{ partial "header.html" $page }} + <div id="main"> + <div id="content"> + <div> + <article role="article"> + <header> + <h1 class="entry-title"> + {{ $.Title }}: + </h1> + </header> + <ul> + {{ with $.Site.Params.sortTaxonomyAlphabetical }} + {{ if eq . true }} + {{ $.Scratch.Set "terms" $data.Terms.Alphabetical }} + {{ end }} + {{ end }} + <!-- Non-relative paths also work - fallback in case the relative path stops working --> + {{ range $key, $value := ($.Scratch.Get "terms") }} + <!-- <li><a href="{{ $.Site.BaseURL }}{{ $data.Plural }}/{{ $value.Name | urlize }}">{{ humanize $value.Name }}</a> {{ $value.Count }}</li> --> + <li><a href="{{ $value.Name | urlize }}">{{ humanize $value.Name }}</a> {{ $value.Count }}</li> + {{ end }} + </ul> + </article> + </div> + + {{ partial "sidebar.html" $page }} + </div> + </div> + + {{ partial "footer.html" $page }} + +{{ end }} diff --git a/sample-config.toml b/sample-config.toml index 1c53eb8..d70c54f 100644 --- a/sample-config.toml +++ b/sample-config.toml @@ -148,11 +148,17 @@ post = "/blog/:year-:month-:day-:title/" # change the post URL to look like the notFoundText = """Please either go back or use the navigation/sidebar menus. """ - # Set to true to hide ReadingTime on posts - disableReadingTime = false + # Set to true to hide ReadingTime on posts + disableReadingTime = false - # Set to true to disable downloading of remote Google fonts - disableGoogleFonts = false + # Set to true to disable downloading of remote Google fonts + disableGoogleFonts = false + + # Generate taxonomy pages + generateTaxonomyList = true + + # This is not needed unless alphabetical sort is needed + # sortTaxonomyAlphabetical = true # Blackfriday is Hugo's markdown engine. Options are at: https://gohugo.io/overview/configuration/ (scroll down to "Configure Blackfriday rendering") |