Closed nhoizey closed 8 years ago
Same issue for me. {{ page | tags}}
injects the full page HTML.
Tag page appears to still work correctly.
Manually building tag links works.
{% for tag in page.tags %}
<a href="{{ site.baseurl }}/tag/{{tag | downcase}}/">{{tag}}</a>
{% endfor %}
@brandongoode IMHO, manually building tag links only uses Jekyll, not the plugin, that's why it works… ;-)
@nhoizey Completely agree. More of just a work around. The plugin still builds the tag pages for me, so that is still useful.
@brandongoode you should use slugify
instead of downcase
, if you have tags containing multiple words, special characters, or letters with accents, like I do.
@nhoizey good advice. I'm sure it will save me some headaches down the road. Thanks.
@brandongoode you're welcome!
If anyone is looking for something that will assign the set-<n>
class to the tag links (so that each frequency is unique), I use this to generate the cloud:
{% capture tags %}
{% for tag in site.tags %}
{{ tag[1].size}}#{{ tag[0] }}
{% endfor %}
{% endcapture %}
{% assign sortedtags = tags | split: ' ' | sort %}
{% assign freqs = '' %}
{% for tag in sortedtags %}
{% assign tagitems = tag | split: '#' %}
{% unless freqs contains tagitems[0] %}
{% capture freqs %}
{{ freqs }}|{{ tagitems[0] }}
{% endcapture %}
{% endunless %}
{% endfor %}
{% assign freqs = freqs | remove_first: '|' | split: '|' %}
{% assign sets = '' %}
{% for freq in freqs %}
{% capture set %}
{% assign setsize = sets | split: "|" | size %}
{% capture a %}
{{ site.tag-var | times: forloop.index}}
{% endcapture %}
{% capture b%}
{{ setsize | times: freqs.size }}
{% endcapture %}
{% capture num %}
{{ a | minus: b}}
{% endcapture %}
{{ num | divided_by: freqs.size }}
{% endcapture %}
{% assign sets = sets | append: set%}
{% endfor %}
{% capture tags %}
{% for tag in site.tags %}
{{ tag[0] }}#{{ tag[1].size }}
{% endfor %}
{% endcapture %}
{% assign sortedtags = tags | split: ' ' | sort %}
{% for tag in sortedtags %}
{% assign tagitems = tag | split: '#' %}
{% assign counter = 0 %}
{% for freq in freqs %}
{% assign stripedfreq = freq | strip %}
{% if stripedfreq == tagitems[1] %}
{% assign splitsets = sets | split: ' ' %}
<a href="{{ site.baseurl }}/archive/tag/{{ tagitems[0] }}" class="set-{{ splitsets[counter] }}">{{ tagitems[0] }}</a>
{% endif %}
{% assign counter = counter | plus: 1 %}
{% endfor %}
{% endfor %}
Make sure to insert tag-var: 5
into your _config.yml, it controls how many sets there are. In this case, there will be 5 sets generated, with numbers 0-4. If you want 10 sets, insert tag-var: 10
instead.
It is probably more complicated than it has to be due to me not yet fully grasping how arrays work in liquid, but it works for me (but if anyone has any suggestions to clean it up, I will happily take them).
I then use jekyll-archives to generate the tag pages.
I believe that this covers the full functionality offered by this plugin (cloud generation with set classes, tag page generation) except for the feeds feature.
Adding
Liquid::Template.register_filter(Jekyll::Filters)
after
require 'jekyll/tagging'
seems to be a quick fix.
@pattex, why does @WillyPillow's workaround fix it, and how can this be manifested into the gem?
@tohuw My guess is that in 3.2.0, Jekyll doesn't enable plugin filters unless explicitly registered, while the previous versions did. Keep in mind that I'm far from familiar with Jekyll and this is just a rough guess :)
Yes, @WillyPillow is right. Filters have to be registered. I just fixed it in d58fd53.
Thanks a lot and greetings pattex - the worst open source maintainer of the galaxy
Awesome, thanks!
No waiting for the release on Rubygems… ;-)
(You're not the worst maintainer, obviously!)
The plugin works well with Jekyll 3.1.6, but stops working when upgrading to Jekyll 3.2.0
{{ page | tags }}
doesn't generate anything, and even breaks the rest of the generated HTML.