preface

How can a self-built blog have no categories and tags, so I went to find out how to configure categories and tags.

1. Configure the classification

1.1 Configuring categories in topics

For example, under the Next theme, go to the config file \themes\next_config.yml under the hexo blog project folder. Then open this file and find the following code

menu:
  home: / || fa fa-home
  # about: /about/ || fa fa-user
  tags: /tags/ || fa fa-tags
  categories: /categories/ || fa fa-th
  archives: /archives/ || fa fa-archive
  # schedule: /schedule/ || fa fa-calendar
  # sitemap: /sitemap.xml || fa fa-sitemap
  # commonweal: /404/ || fa fa-heartbeat

Copy the code

And then let go of categories: / categories / | | fa fa – th classification in this line of code that has been configured.

1.2 Creating Classified Directory Files

Because the category page does not have a default page, we need to create the category page manually.

Open the command line, go to the blog project folder, and execute the following command

$ hexo new page categories
Copy the code

Success will prompt:

INFO  Created: ~/blog/source/categories/index.md
Copy the code

So we have created the categories page. At this point, however, the topic does not recognize the page as a category page; So we need to edit the new page so that the theme recognizes the page and automatically displays categories for the page.

1.3 Edit the page so that the topic recognition page is classified page

As mentioned above, we need to edit the page so that the topic can identify the page as a classified page. We just need to open the page file index.md according to the prompt path after success, and the default content after opening is

-- Title: Article classification Date: 2021-01-25 22:37:25 --Copy the code

We need to add type: “Categories” to make the subject recognize the page as a category page

-- Title: Article category Date: 2021-01-25 22:37:25 Type: "Categories" --Copy the code

We have completed the configuration of the entire category page

1.4 Set classification attributes for articles

First open the need to add classification of the article, in the article to add the following copy set up the classification

---
categories: 
- Android
---
Copy the code

As above categories:Android means to add this article to the “Android” category. Then we can see the category in the blog to the category.

// Set categories -- categories: -android-xxx --Copy the code

If the secondary classification is set as above, this article is under XXX of Android classification.

2. Configure labels

2.1 Configuring labels in topics

For example, under the Next theme, go to the config file \themes\next_config.yml under the hexo blog project folder. Then open this file and find the following code

menu:
  home: / || fa fa-home
  # about: /about/ || fa fa-user
  tags: /tags/ || fa fa-tags
  categories: /categories/ || fa fa-th
  archives: /archives/ || fa fa-archive
  # schedule: /schedule/ || fa fa-calendar
  # sitemap: /sitemap.xml || fa fa-sitemap
  # commonweal: /404/ || fa fa-heartbeat

Copy the code

And then let go of tags: / tags / | | fa fa – tags classification in this line of code that has been configured.

2.2 Creating label Directory Files

Just like category pages, tabs don’t have a default page so you need to create tabs manually.

Open the command line, go to the blog project folder, and execute the following command

$ hexo new page tags
Copy the code

Success will prompt:

INFO  Created: ~/blog/source/tags/index.md
Copy the code

So we’ve created the TAB page. But at this point the theme doesn’t recognize the page as a TAB; So we need to edit the new page so that the theme recognizes the page and automatically displays the label for the page.

2.3 Edit the page so that the theme identification page is a TAB page

As mentioned above, we need to edit the page so that the theme can identify the page as a TAB page. We just need to open the page file index.md according to the prompt path after success

-- Title: Tag Date: 2021-01-25 22:54:58 --Copy the code

We need to add type: “tags” to make the topic recognize the page as a tag page

---
title: 标签
date: 2021-01-25 22:54:58
type: "tags"
---
Copy the code

We are done configuring the entire TAB page

2.4 Set tag attributes for articles

First of all, open the article that needs to add the label, add the following copy in the article, and then set up the label

// Set single tags -- tags: - Facebook configuration -- // Set multiple tags and set categories -- Categories: - Android tags: - Android - RecyclerView --Copy the code

Add the “Facebook Profile” sub-tag to this article. Then we can see the tag in the blog to tag.

3. The conclusion

In this way, categories and labels are configured. The configuration process of categories and labels is basically the same.

For more information about Next configuration, see the official documentation theme-next.iissnan.com/theme-setti…

Extension 4.

Above we configure the Front-matter area at the top of the pair file, which is used to specify the configuration variable area of the individual file