forked from sujaykundu777/devlopr-jekyll
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
1e8704b
commit 863f6c5
Showing
4 changed files
with
60 additions
and
48 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
--- | ||
layout: post | ||
title: "Adding Multiple Categories in Posts" | ||
summary: "Learn how to add categories in posts" | ||
author: xplor4r | ||
date: '2021-02-28 1:35:23 +0530' | ||
category: ['jekyll','guides', 'sample_category'] | ||
tags: jekyll | ||
thumbnail: /assets/img/posts/code.jpg | ||
keywords: devlopr jekyll, how to use devlopr, devlopr, how to use devlopr-jekyll, devlopr-jekyll tutorial,best jekyll themes, multi categories and tags | ||
usemathjax: false | ||
permalink: /blog/adding-categories-tags-in-posts/ | ||
--- | ||
|
||
## Adding Multiple Categories in Posts | ||
|
||
To add categories in blog posts all you have to do is add a **category** key with category values in frontmatter of the post : | ||
|
||
``` | ||
--- | ||
category: ['jekyll', 'guides', 'sample_category'] | ||
--- | ||
``` | ||
|
||
Then to render this category using link and pages. All we need to do is, Create a new file with [your_category_name].md inside categories folder. Then copy the below code, replacing all the values with your_category_name. For eg. to create a category with your_category_name. | ||
|
||
To add a category with name "sample_category", use this | ||
|
||
In categories/sample_category.md | ||
|
||
```jsx | ||
--- | ||
layout: page | ||
title: Guides | ||
permalink: /blog/categories/sample_category/ | ||
--- | ||
|
||
<h5> Posts by Category : {{ page.title }} </h5> | ||
|
||
<div class="card"> | ||
{% for post in site.categories.sample_category %} | ||
<li class="category-posts"><span>{{ post.date | date_to_string }}</span> <a href="{{ post.url }}">{{ post.title }}</a></li> | ||
{% endfor %} | ||
</div> | ||
``` | ||
|
||
Using the category, all the posts associated with the category will be listed on | ||
`http://localhost:4000/blog/categories/sample_category` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,13 @@ | ||
--- | ||
layout: page | ||
title: Jekyll | ||
permalink: /blog/tags/jekyll | ||
--- | ||
<h5> Posts by Tag : {{ page.title }} </h5> | ||
|
||
<div class="card"> | ||
{% for post in site.tags.jekyll %} | ||
<li class="category-posts"><span>{{ post.date | date_to_string }}</span> <a href="{{ post.url }}">{{ post.title }}</a></li> | ||
{% endfor %} | ||
--- | ||
layout: page | ||
title: Guides | ||
permalink: /blog/categories/sample_category/ | ||
--- | ||
|
||
<h5> Posts by Category : {{ page.title }} </h5> | ||
|
||
<div class="card"> | ||
{% for post in site.categories.sample_category %} | ||
<li class="category-posts"><span>{{ post.date | date_to_string }}</span> <a href="{{ post.url }}">{{ post.title }}</a></li> | ||
{% endfor %} | ||
</div> |
This file was deleted.
Oops, something went wrong.