categories-archives-and-tags-shopify-blog

By default there is neither blog categories nor archives in shopify, all you have is tags. There is one another way to get separate categories using metafields but in this blog i’m going to write about how to utilize tag feature as categories, tags and archives.

The idea here is to create categories and archives as tags.

Categories :

  1. Let’s create categories as a tag along with other tags.
  2. Write schema that would list our categories.
  3. Print categories filtering from tags.

Archives :

  1. Create archives as a tag following a pattern along with other tags.
  2. Print Archives filtering from tags.

Tags :

Now as we have mixed all categories and archives as tags, we have to only retrieve those tags excluding categories and archives to present as tags.

1.Blog Categories

Create a blog-sidebar  section and associate on blog page.

  • Navigate to section and add a template name blog-sidebar.liquid
  • include a sidebar on blog page

  • on blog-sidebar.liquid add a schema like below which would add a textarea field to list tags that we are considering as a blog category

  • The above schema on blog-sidebar section would create a field on blog section on customize theme. (Online store > customize theme > navigate to blog page on the preview section to view)

blog-sidebar

  • Now add tags that you are considering as blog categories separated with comma, in the above screenshot summer and another are tags.
  • on the same blog-sidebar section add these codes

The code above would print tags that we have separated as categories.

2. Blog archives

For archives we are doing this trick of adding year and month as a tags on the blog post and listing them by grouping.

On a blog post add a {{year}} { {month}} as a tags. for. eg 2017 january and add this code below on same blog-sidebar section that would group and shows archives.

3. Tags

Tags are default by shopify but direct listing would list the categories and archives tags as well. so we will filter them out.

 

Suman K.C

eCommerce Developer, writes about stuff related to eCommerce development. Currently based in Kathamandu, loves reading about startups & new technology, introvert nature, fond of traveling & playing volleyball.

More Posts - Website

Follow Me:
LinkedInGoogle Plus