jekyll tags
propósito
- anotar las diferentes usar tags y nubes de tags en jekyll
- es dificil encontrar lo correspondiente a
site.tags
para las pages algo así como unpage.tags
formato de los tags
- el formato de tags con este forma
tags:
- convocatorias
- meritos
- reunion
- si usamos este
tags:
- jekyll tags
- interpreta que hay un solo tag que es jekyll tags
tags en pages y posts
- usar los tags para los posts es sencillo pero combinar tags en posts y pages no lo es tanto.
- en el layout
page.html
ypost.html
{% raw %}
{% if page.tags.size > 0 %}
Etiquetas:
{% assign tags = page.tags | sort %}
{% include tagcloud.html %}
{% endif %}
{% endraw %}
- para que salga la información sobre las etiquetas solo si hay alguna.
- el archivo
tagcloud.html
{% raw %}
{% for tag in tags %}
{% assign counter = '0' %}
{% for page in site.pages %}
{% if page.tags contains tag %}
{% capture counter %}{{ counter | plus:'1' }}{% endcapture %}
{% endif %}
{% endfor %}
{% for post in site.posts %}
{% if post.tags contains tag %}
{% capture counter %}{{ counter | plus:'1' }}{% endcapture %}
{% endif %}
{% endfor %}
<a href="{{ site.baseurl }}/tags/#{{ tag | slugize }}" class="btn btn-primary btn-xs">{{ tag | slugize }}
<span class="badge">{{ counter}}</span>
</a>
{% endfor %}
{% endraw %}
-
se encarga de informar el contador de los posts y pages que usan ese taga con enlaces a la página
tag
-
el archivo
tag
se comenta por si mismo
{% raw %}
{% comment %}
=======================
intento de unir todo
sobre [este post ](http://codinfox.github.io/dev/2015/03/06/use-tags-and-categories-in-your-jekyll-based-github-pages/)
The following part extracts all the tags from your posts and sort tags, so that you do not need to manually collect your tags to a place.
=======================
{% endcomment %}
{% assign rawtags = "" %}
{% for post in site.posts %}
{% assign ttags = post.tags | join:'|' | append:'|' %}
{% assign rawtags = rawtags | append:ttags %}
{% endfor %}
{% for page in site.pages %}
{% assign ttags = page.tags | join:'|' | append:'|' %}
{% assign rawtags = rawtags | append:ttags %}
{% endfor %}
{% assign rawtags = rawtags | split:'|' | sort %}
{% comment %}
=======================
The following part removes dulpicated tags and invalid tags like blank tag.
=======================
{% endcomment %}
{% assign tags = "" %}
{% for tag in rawtags %}
{% if tag != "" %}
{% if tags == "" %}
{% assign tags = tag | split:'|' %}
{% endif %}
{% unless tags contains tag %}
{% assign tags = tags | join:'|' | append:'|' | append:tag | split:'|' %}
{% endunless %}
{% endif %}
{% endfor %}
{% comment %}
=======================
sacando la información de en que post o pages este el tag.
Primero la nube de tags
=======================
{% endcomment %}
<div class="tags-expo-list">
{% for tag in tags %}
<a href="#{{ tag | slugify }}" class="btn btn-primary btn-xs">{{ tag }}</a>
{% endfor %}
</div>
{% comment %}
=======================
sacando la información de en que post o pages este el tag.
Ahora los paginas o posts que los tienen
=======================
{% endcomment %}
{% for tag in tags %}
<h2 id="{{ tag | slugify }}">{{ tag }}</h2>
<ul>
{% for page in site.pages %}
{% if page.tags contains tag %}
<li><a href="{{ site.baseurl }}{{ page.url }}">{{ page.title }}</a></li>
{% endif %}
{% endfor %}
{% for post in site.posts %}
{% if post.tags contains tag %}
<li><a href="{{ site.baseurl }}{{ post.url }}">{{ post.title }}</a></li>
{% endif %}
{% endfor %}
</ul>
{% endfor %}
{% endraw %}
sitio para probar
- nueva en
C:\nube\MEGA\programacion\HtmlCssEstatico\jekyll\nueva
sitios con ejemplos
- un buen blog de zpbappi
- sitio de un sysadmin
- con enlaces a otros sitios