How to save posts by date, tags, and categories in Shopify

You are meeting troubles with saving posts by dates, tags, and categories? Don’t be worried because we are here to give you the detailed instruction on how to address your issue with Jekyll Archives. Jekyll Archives allows you to generate pages listing posts by their tags, dates, and categories.

However, please keep reading our instructional writing on how to save posts by date, tags, and categories to find out the solution.

How to save posts by date, tags, and categories

1. Installation {#1-installation}

Step 1: Create a Gemfile

To get started, there may be some definitions that we should clarify.

A Gem is a collection of code that we can include in Ruby projects. It enables us to take codes from anyone and drop them into your project. There are several functions that Gems can perform like:

  • Pagination
  • Interact with APIs like Github
  • Converting a Ruby object to JSON

For your information, Jekyll is a Gem similar to a lot of Jekyll plugins including jekyll-archives, jekyll-seo-tag, and jekyll-feed.

A Gemfile is the dependency management system of Ruby. That is to say, it is a list of Gems that a Ruby project needs to run.

Also, we need to run bundle install to create a gemfile.lock file and download the Gems in gemfile.lock. Please run:

gem install bundler

Step 2: In your Gemfile, add jekyll-archives to the jekyll_plugins group:

source 'https://rubygems.org'

gem 'jekyll', '3.3.1'

group :jekyll_plugins do
  gem 'jekyll-archives'
end

Step 3: Run bundle install

2. Configuration {#2-configuration}

All configuration is set in _config.yml that is under the arrchives key. However, the default configuration is set to the code given below:

jekyll-archives:
  enabled: []
  layout: 'archive'
  permalinks:
    year: '/:year/'
    month: '/:year/:month/'
    day: '/:year/:month/:day/'
    tag: '/tag/:name/'
    category: '/category/:name/'

Enabled

It describes which types of archive are enabled. All options include all or the array of any combination of month, year, day, tags, categories.

enabled: all
enabled:
  - categories
enabled:
  - year
  - month
  - tags

Layout

To be used if there is no type-specific layout which is set.

layout: archive

Type specific layout

Layouts for particular types of archives.

layouts:
  year: year-archive
  month: month-archive
  day: day-archive
  tag: tag-archive-layout

Customize the format of the permalink of the archive pages.

permalinks:
  year: '/archives/year/:year/'
  month: '/archives/month/:year-:month/'
  tag: '/archives/tag/:name/`

3. Usage {#3-usage}

You are able to link to the permalink you have just set up whenever the plugin is set up. There is a category called jekyll-plugins on this site so I am able to link to it like this:

<a href="/categories/jekyll-plugins/">Plugins</a>

All the categories and links to their archive pages can be outputted by looping of site.categories:

<ul>

  
  <li>
    <a href="/category/start/">start</a>
  </li>

Conclusion

Please read the instruction above carefully so that you can save posts in your favorite way.