parsiya / Hugo-Octopress

Port of the classic Octopress theme to Hugo
MIT License
155 stars 52 forks source link

LIst of taxonomies #21

Closed dirk2011 closed 8 years ago

dirk2011 commented 8 years ago

Thanks for the Octopress theme for Hugo. I like it very much.

Before I used the theme Hyde Y. It could make a list of taxonomies and how often one was used. I am missing that in Octopress. Is it possible to add this, or could you give me a hint how to do this? Sample

parsiya commented 8 years ago

Shouldn't be too complicated. Do you want a list for both categories and tags together or separate for each?

dirk2011 commented 8 years ago

Thanks, I would prefer seperated.

parsiya commented 8 years ago

Check the taxonomoy-stats-issue-21 branch. I believe it is what you want.

The solution was a lot easier than I expected and only needed me to put some boilerplate code from the documentation into layouts/_default/terms.html.

Now you see the stats at /tags/ and /categories/. I can modify the tags: and categories text. I think your example did not have the colon.

Here are two screenshots: categories-page tags-page

dirk2011 commented 8 years ago

Great thanks for this update. The index pages voor tags and categories are now generated, and even for an other taxonomy I use. But the links are not working yet. For tags in is in the url a double "tags" and for categories the same. Sample Could you fix this?

parsiya commented 8 years ago

Hmm. I think I looked at the output last night and checked if it is correct. But then again it was 2 am and I might have imagined checking it.

Should be fixable with a little bit of changing. I will look at it tonight.

Thanks for catching my error.

dirk2011 commented 8 years ago

2 am is too late :-)

I think I got it.

        <ul>
        {{ $baseurl := .Site.BaseURL }}
          {{ $data := .Data }}
          {{ range $key, $value := .Data.Terms.ByCount }}
          <li> 
             <a href="{{ $baseurl }}{{ $data.Plural }}/{{ $value.Name | urlize }}">{{ humanize $value.Name }}</a> {{ $value.Count }}
          </li>
          {{ end }}
        </ul>

I looked at the file terms.html of the Hyde-Y theme and got it working. I added the $baseurl var, and in the link. Its working now for tags, and categories. I also fill a taxonomy "updated" with for example "2016-08-23" that one is generating not working links.

parsiya commented 8 years ago

I also fill a taxonomy "updated" with for example "2016-08-23" that one is generating not working links.

I am a bit confused. Do you mean it's working or no?

Do you mean if you create a tag named 2016-08-23 it will not work? It works but humanize will remove the dashes when it displays the tag.


What you have done will work. You just need to use {{ $.Site.BaseURL }} like this:

<ul>
  {{ $data := .Data }}
  {{ range $key, $value := .Data.Terms.ByCount }}
    <li><a href="{{ $.Site.BaseURL }}{{ $data.Plural }}/{{ $value.Name | urlize }}">{{ humanize $value.Name }}</a> {{ $value.Count }}</li>
  {{ end }}
</ul>

Also the following will work (because we are already in /tags/ or /categories/ so we just need to go into the tag)

<ul>
  {{ $data := .Data }}
  {{ range $key, $value := .Data.Terms.ByCount }}
    <li><a href="{{ $value.Name | urlize }}">{{ humanize $value.Name }}</a> {{ $value.Count }}</li>
  {{ end }}
</ul>
dirk2011 commented 8 years ago

Thank you very much for your support and explanations. I also changed the order from .Data.Terms.ByCount in .Data.Terms.Alphabetical. Yes its working now and I like it.

parsiya commented 8 years ago

Great, I will add the two options to the config files and merge it:

  1. To generate the tags/categories
  2. To be bycount or alphabetical