minddust / minddust.github.io Goto Github PK
View Code? Open in Web Editor NEWHome Page: www.minddust.com
Home Page: www.minddust.com
Re: http://www.minddust.com/post/tags-and-categories-on-github-pages/
It's possible to get rid of this double for lookup:
{% for post_tag in post.tags %}
{% for data_tag in site.data.tags %}
{% if data_tag.slug == post_tag %}
{% assign tag = data_tag %}
{% endif %}
{% endfor %}
Instead you could write a much nicer:
{% for post_tag in post.tags %}
{% assign tag = site.data.tags[post_tag] %}
Your tags.yml
currently looks like this:
- slug: django
name: Django
- slug: django-template-tags
name: Django Template Tags
- slug: font-awesome
name: Font Awesome
- slug: icons
name: Icons
and the above works if you restructure it like so:
django:
slug: django
name: Django
django-template-tags:
slug: django-template-tags
name: Django Template Tags
font-awesome:
slug: font-awesome
name: Font Awesome
icons:
slug: icons
name: Icons
with the added benefit of {{site.data.tags.icons.name}}
, should you want to do that. It makes more sense if you're crossreferencing projects. The dot notation even works with font-awesome
, probably because Liquid is not a full-fledged language and -
doesn't mean minus.
and since you only used slug to look the tag up, you it's not needed any more:
django:
name: Django
django-template-tags:
name: Django Template Tags
font-awesome:
name: Font Awesome
icons:
name: Icons
Regarding /blog/tag/{{ tag.slug }}/
, since tag.slug == post_tag
was true you can use post_tag
to create the url. This is really question of taste though, if you don't mind duplicating the slug as tag key in yaml you could use the uniform tag.slug version.
When you're listing all tags you can use
{% for data_tag_entry in site.data.tags %}
{% assign data_tag_slug = data_tag_entry[0] %}
{% assign data_tag = data_tag_entry[1] %}
so the slug is not lost.
This obviosly works for all data ymls.
Hi, have you found a way to auto-generate the content in the _my_tags
and _my_categories
folders? As long as it works locally the same effect could be achieved as the files would be committed to source code and Github Pages is none the wiser. I'm new to Ruby/Jekyll so I'm not sure where to start, I get the sense that the plugin examples I've seen generate content in _site, which isn't what we want.
Thanks!
Hi there,
In your blog post, HOW TO USE TAGS AND CATEGORIES ON GITHUB PAGES WITHOUT PLUGINS, you supply an incomplete example of the code needed to set the system up. In the implementation of the website, you have one extra line above what you have mirrored in the post:
{% assign post = page %}
This line is crucial to the rest of the code working, since (at least as of now) Jekyll uses 'page' instead of 'post'.
After I added that line, implementing the rest was extremely easy and very well documented, especially with the full implementation available for perusal. I am very grateful that you took the time to figure this out, and thought you might be unaware of the above omission.
I've read your post about categories and tags on github pages. It was exactly what I was looking for. However, I could only get it working untill I saw that I've missed something.
You have to add this: {% assign post = page %}
at the top of the post layout. Alternatively, you could replace post
by page
in the subsequent code. I know the earlier post does contain this statement. But when writing code examples, the code should be complete.
Hi Stephan -- thank you so much for helping me figure out the tags. I've found your site to be extremely useful! I have a followup question. I have a page with a list of posts by tag. the code is below. I'd like to add a LINK to each tag name that goes to the permalink location for tag.
so for example this is a page that i built using your code that calls the HDF5 tag!
http://lwasser.github.io/NEON_HigherEd/HDF5/
to create a URL path i'd like to use the slug in the tags.yml page because that will never have spaces in it. Can you provide a bit of direction regarding how i would modify the code below to find the slug for each tag? (if that makes sense?) i've tried several things - none of which have worked.
thank you for any direction!
Leah
by Tag
{% assign post = page %}
{% for tag in site.tags %}
<h3><a name="{{ tag | first }}">{{ tag | first }}</a></h3>
{% for posts in tag %}
{% for post in posts %}
<article>
{% if post.url %}
<h2><a href="{{ post.url | prepend: site.baseurl }}">{{ post.title }}</a></h2>
<p>{% if post.description %}{{ post.description }}{% else %}{{ post.content | strip_html | strip_newlines | truncate: 120 }}{% endif %}</p>
{% endif %}
</article>
{% endfor %}
{% endfor %}
{% endfor %}
Hi,
Loving your tag and category tutorials; just what I was looking for! (Although #9 is an interesting question...)
My question is about the layout:
https://github.com/minddust/minddust.github.io/blob/master/_layouts/blog_by_category.html
In here you treat the my_categories as a hash, rather than an array. For me, that collection is an array; I cannot access them by slug, but instead by numeric ID... Eg:
site.categories[0].slug
-- works
site.categories['example'].slug
-- does not work
Also youre collection is my_categories
but you use categories
in site
?
Hey Stephan,
I've tried to clone your solution for adding jekyll tags and categories
http://www.minddust.com/post/tags-and-categories-on-github-pages/
I've got the tags and categories displaying but the URL links to the '/blog/tag' and '/blog/category' all fail.
http://emeraldjava.github.io/blog/boston-2015-w1/
Do i need to register the 'blog' folder somewhere else in the jekyll config. Any help or advice would be appreciated.
Danke,
Paul
The sitemap line in robots.txt doesn't render correctly since there isn't a front matter in that file. Adding two ---
lines at the start of the file should be enough to fix it.
The tutorial provided is very helpful, and a good solution, but the second post is very misleading.
The wording used implies (or seems to) that the instructions to have a full tagging solution are in that posts, but it's actually missing some bits, for example, the creation of the blog_by_tag
layout.
While this may be obvious for people working with Jekyll, it's very confusing for people who don't know anything about Jekyll, and assume that implementations would only take a few minutes :-)
The GitHub link at http://www.minddust.com/project/jquery-pjaxr/ points to itself because of this:
2509667#diff-70bedf1ce421bc33ea4bc5a9bcad356bR21
#3 ? I am still wrapping my head around collections and categories and so for this implementation keeps my source dir pretty clean. Now to muss it up, but not by much I found this: jekyll/jekyll#1141
which taught me that sudir/_posts works for categories but it is not hitting in the blog_by_category layout.
forgive me as I am just starting out and I am sure it is something to do with the loop. I will do my best to figure out how I can do this but I thought you might have an idea. Oh, and i couldn't figure out how to label this a question
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.