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/:title
to 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-abbrlink
The 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.yml
the configuration file
## permalink: :year/:month/:day/:title/
permalink: posts/:abbrlink.html ## 此处可以自己设置,也可以直接使用 :/abbrlink
_config.yml
Add the following configuration under the configuration file
If you are butterfly
a 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 supportscrc16
andcrc32
algorithm, default value iscrc16
)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
Using the URL generated by the plugin
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