Hexo: hexo uses the hexo-abbrlink plugin to generate permanent links


the cover

Original link: Hexo: hexo uses the hexo-abbrlink plugin to generate permanent links | Elvin

foreword

  • The default static URL format of Hexo is :year/:month/:day/:titleto generate fixed links in the form of year, month, day and title

​ For example:http://www.xxx.com/2022/11/08/文章标题

​ The format of the default URL will produce a lot of slashes. When Baidu Spider crawls a webpage, it will crawl the webpage according to the weight of the webpage, such as the first homepage to be crawled (usually its own domain name, which is relatively short), so it is not suitable in the link There are too many slashes, preferably no more than two

​ Another problem is that if the title of the article is in Chinese, the URL will become very long after transcoding. I will post a comparison picture at the end.

  • hexo-abbrlinkThe above problems can be solved by using a plug-in. In the past, modifying the title will cause the original link to become invalid. After using this plug-in, as long as the abbrlink value in the article is not changed, the link of the article will be persistent

operate

1. Install the plug-in

npm install hexo-abbrlink --save

Specific plug-in link: hexo-abbrlink

2. Configuration

Modify _config.ymlthe configuration file

## permalink: :year/:month/:day/:title/
permalink: posts/:abbrlink.html  ## 此处可以自己设置,也可以直接使用 :/abbrlink

_config.ymlAdd the following configuration under the configuration file

If you are butterflya theme, you should have created a theme configuration yml (mine _config.butterfly.yml), and the following configurations can also be placed in the custom theme configuration yml file

## abbrlink config
abbrlink:
  alg: crc32      #support crc16(default) and crc32 进制
  rep: hex        #support dec(default) and hex  算法
  drafts: false   #(true)Process draft,(false)Do not process draft. false(default) 
  ## Generate categories from directory-tree
  ## depth: the max_depth of directory-tree you want to generate, should > 0
  auto_category:
     enable: true  #true(default)
     depth:        #3(default)
     over_write: false 
  auto_title: false #enable auto title, it can auto fill the title by path
  auto_date: false #enable auto date, it can auto fill the date by time today
  force: false #enable force mode,in this mode, the plugin will ignore the cache, and calc the abbrlink for every post even it already had abbrlink.
  • alg: Algorithm (currently supports crc16and crc32algorithm, default value is crc16)
  • rep: format (the generated link can be in hexadecimal or decimal format, the default value is in decimal format)

example

crc16 & hex
https://test.com/posts/55c6.html
crc16 & dec
https://test.com/posts/43212.html

crc32 & hex
https://test.com/posts/6ec16a2c.html
crc32 & dec
https://test.com/posts/1521457752.html

For more configuration, please refer to the specific plug-in link: hexo-abbrlink

Show results

URL generated by default

pic_1

Using the URL generated by the plugin

pic_2

The URL generated by the plugin will be more concise and clear

reference link

Hexo Blog Generating Permalinks

SEO optimization: Hexo-abbrlink plugin generates permanent fixed links


More knowledge is being continuously updated!!!

statement

The source of the original text is indicated in the reference part, and the source of the original text can be obtained at the reference link of the article

If the content in the article involves the original copyright, please contact [email protected] by email , and the related articles or content will be changed or canceled in time

Guess you like

Origin blog.csdn.net/weixin_42464282/article/details/130982114