{"action":"created","issue":{"url":"https://api.github.com/repos/minddust/minddust.github.io/issues/5","labels_url":"https://api.github.com/repos/minddust/minddust.github.io/issues/5/labels{/name}","comments_url":"https://api.github.com/repos/minddust/minddust.github.io/issues/5/comments","events_url":"https://api.github.com/repos/minddust/minddust.github.io/issues/5/events","html_url":"https://github.com/minddust/minddust.github.io/issues/5","id":87811403,"number":5,"title":"Simpler data lookups","user":{"login":"TWiStErRob","id":2906988,"avatar_url":"https://avatars.githubusercontent.com/u/2906988?v=3","gravatar_id":"","url":"https://api.github.com/users/TWiStErRob","html_url":"https://github.com/TWiStErRob","followers_url":"https://api.github.com/users/TWiStErRob/followers","following_url":"https://api.github.com/users/TWiStErRob/following{/other_user}","gists_url":"https://api.github.com/users/TWiStErRob/gists{/gist_id}","starred_url":"https://api.github.com/users/TWiStErRob/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/TWiStErRob/subscriptions","organizations_url":"https://api.github.com/users/TWiStErRob/orgs","repos_url":"https://api.github.com/users/TWiStErRob/repos","events_url":"https://api.github.com/users/TWiStErRob/events{/privacy}","received_events_url":"https://api.github.com/users/TWiStErRob/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":6,"created_at":"2015-06-12T18:23:52Z","updated_at":"2015-07-12T08:56:28Z","closed_at":"2015-06-13T22:47:12Z","body":"Re: http://www.minddust.com/post/tags-and-categories-on-github-pages/\r\n\r\nIt's possible to get rid of this double for lookup:\r\n```\r\n{% for post_tag in post.tags %}\r\n    {% for data_tag in site.data.tags %}\r\n        {% if data_tag.slug == post_tag %}\r\n            {% assign tag = data_tag %}\r\n        {% endif %}\r\n    {% endfor %}\r\n```\r\n\r\nInstead you could write a much nicer:\r\n```\r\n{% for post_tag in post.tags %}\r\n    {% assign tag = site.data.tags[post_tag] %}\r\n```\r\n\r\nYour `tags.yml` currently looks like this:\r\n```\r\n- slug: django\r\n  name: Django\r\n\r\n- slug: django-template-tags\r\n  name: Django Template Tags\r\n\r\n- slug: font-awesome\r\n  name: Font Awesome\r\n\r\n- slug: icons\r\n  name: Icons\r\n```\r\n\r\nand the above works if you restructure it like so:\r\n```\r\ndjango:\r\n  slug: django\r\n  name: Django\r\ndjango-template-tags:\r\n  slug: django-template-tags\r\n  name: Django Template Tags\r\nfont-awesome:\r\n  slug: font-awesome\r\n  name: Font Awesome\r\nicons:\r\n  slug: icons\r\n  name: Icons\r\n```\r\nwith 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.\r\n\r\nand since you only used slug to look the tag up, you it's not needed any more:\r\n```\r\ndjango:\r\n  name: Django\r\ndjango-template-tags:\r\n  name: Django Template Tags\r\nfont-awesome:\r\n  name: Font Awesome\r\nicons:\r\n  name: Icons\r\n```\r\n\r\nRegarding `/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.\r\n\r\nWhen you're listing all tags you can use\r\n```\r\n{% for data_tag_entry in site.data.tags %}\r\n    {% assign data_tag_slug = data_tag_entry[0] %}\r\n    {% assign data_tag = data_tag_entry[1] %}\r\n```\r\nso the slug is not lost.\r\n\r\nThis obviosly works for all data ymls."},"comment":{"url":"https://api.github.com/repos/minddust/minddust.github.io/issues/comments/120702297","html_url":"https://github.com/minddust/minddust.github.io/issues/5#issuecomment-120702297","issue_url":"https://api.github.com/repos/minddust/minddust.github.io/issues/5","id":120702297,"user":{"login":"LovesTha","id":4186379,"avatar_url":"https://avatars.githubusercontent.com/u/4186379?v=3","gravatar_id":"","url":"https://api.github.com/users/LovesTha","html_url":"https://github.com/LovesTha","followers_url":"https://api.github.com/users/LovesTha/followers","following_url":"https://api.github.com/users/LovesTha/following{/other_user}","gists_url":"https://api.github.com/users/LovesTha/gists{/gist_id}","starred_url":"https://api.github.com/users/LovesTha/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/LovesTha/subscriptions","organizations_url":"https://api.github.com/users/LovesTha/orgs","repos_url":"https://api.github.com/users/LovesTha/repos","events_url":"https://api.github.com/users/LovesTha/events{/privacy}","received_events_url":"https://api.github.com/users/LovesTha/received_events","type":"User","site_admin":false},"created_at":"2015-07-12T08:56:28Z","updated_at":"2015-07-12T08:56:28Z","body":"Thanks for this its really good. I'm just trying to figure out how to have the blog_by_tag.html list the nice friendly name for the tag not the slug. The post layout uses 'tag.name' so the first thing that occured to me was that where the BbT.html uses 'page.tag' to display the slug that 'page.tag.name' should work, but that doesn't.\r\n\r\nOther various things I've tried haven't done anything and I have no idea how this stuff is working."}}