大峰笔记
  • 关于
  • 搜索

Hugo使用笔记 Thu, Dec 2, 2021

2021年12月1日,从hexo转到了hugo,生成静态文件的速度确实很快,但转过来发生了一些问题,记录一下:

1,从hexo迁移到hugo,需要将permalinks定义为下面这种形式以适应之前的URL,在config.toml最下面添加就行,这样配置会改变content/post/文件夹下所有文章的URL。(content/post/文章名.md的URL将从默认的https://example.com/post/文章名/改变为https://example.com/2013/11/01/文章名/)

[permalinks]

post = “/:year/:month/:day/:title/”

其它可用属性: /:monthname/:day/:weekday/:weekdayname/:yearday/:section/:title/:slug/:filename/

2,设置文章摘要,在config.toml中设置,这样就不再需要使用more标签了

hasCJKLanguage = true

summaryLength = 200

3,页面导航排序,在config.toml中设置

[[menu.main]] name = “Home” weight = 5 ————————这个5是排序功能,数字小,排在前面

本博客使用的是even主题,某些细节进行了修改。

hugo的一些操作命令:

hugo version —验证安装是否成功

hugo new site 博客名称 —建立博客

hugo new post/第一篇文章.md —写文章

hugo –minify —压缩HTML、JS、CSS等文件

hugo —生成静态文件

hugo server —在本地预览博客,如有修改,会实时更新,除了修改css,需要重新hugo server

hugo与hexo命令比较

生成静态文件:hugo是输入hugo;hexo是输入hexo g

本地预览网站:hugo是输入hugo server;hexo是hexo s

clean静态文件:hugo是hugo –gc –cleanDestinationDir;hexo是hexo clean

暂时先记录这些。


较新的一篇: 15000公里保养
较旧的一篇: hugo新发现

Back to Home | bXpmOTk5QHFxLmNvbQ== | TOP ↑
hugo.386 | © 2025 | 苏ICP备2022047275号-1,苏公网安备 32020602001142号