商汇粹外网资源平台

搜索
查看: 1043|回复: 3

使用hexo new "page名称"的时候,名称内部的空格和括号会变成短横线,咋解 ...

[复制链接]

该用户从未签到

4

主题

5

帖子

13

积分

新手上路

Rank: 1

积分
13
发表于 2022-11-24 13:43:50 | 显示全部楼层 |阅读模式
$ hexo new page "XX 相关知识及使用 (二)"
INFO  Created: D:\qqdownload\hexo\source\XX-相关知识及使用-二\index.md
回复

使用道具 举报

该用户从未签到

4

主题

8

帖子

50

积分

注册会员

Rank: 2

积分
50
发表于 2022-11-24 14:06:03 | 显示全部楼层
从新按照教程来,我这里有hexo详细教程:http://Kangchou001.cn
回复

使用道具 举报

该用户从未签到

2

主题

17

帖子

75

积分

注册会员

Rank: 2

积分
75
发表于 2022-11-24 14:28:16 | 显示全部楼层
不用加引号,直接hexo new page XX 相关知识及使用 (二),你试一下,新建文章都是不用在标题名上加引号的。
回复

使用道具 举报

该用户从未签到

2

主题

17

帖子

75

积分

注册会员

Rank: 2

积分
75
发表于 2022-11-24 14:50:29 | 显示全部楼层
其实hugo这样做是比较符合url的规范的,也建议这样做
当然,如果你打算不让它这样做,或许可以自己编译一个魔改的hugo?

// UnicodeSanitize sanitizes string to be used in Hugo URL's, allowing only// a predefined set of special Unicode characters.// If RemovePathAccents configuration flag is enabled, Unicode accents// are also removed.// Spaces will be replaced with a single hyphen, and sequential hyphens will be reduced to one.func (p *PathSpec) UnicodeSanitize(s string) string {        if p.RemovePathAccents {                s = text.RemoveAccentsString(s)        }        source := []rune(s)        target := make([]rune, 0, len(source))        var prependHyphen bool        for i, r := range source {                isAllowed := r == '.' || r == '/' || r == '\\' || r == '_' || r == '#' || r == '+' || r == '~'                isAllowed = isAllowed || unicode.IsLetter(r) || unicode.IsDigit(r) || unicode.IsMark(r)                isAllowed = isAllowed || (r == '%' && i+2 < len(source) && ishex(source[i+1]) && ishex(source[i+2]))                if isAllowed {                        if prependHyphen {                                target = append(target, '-')                                prependHyphen = false                        }                        target = append(target, r)                } else if len(target) > 0 && (r == '-' || unicode.IsSpace(r)) {                        prependHyphen = true                }        }        return string(target)}
如果你是考虑hexo迁移至hugo的问题,那或许可以自己写个脚本把%20改成-
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

快速回复 返回顶部 返回列表