-
Notifications
You must be signed in to change notification settings - Fork 35
从 Hexo 迁移到 Hugo #11
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
你好。请问用nginx + hugo + 这个主题,为什么生成的页面没有css? 谢谢 |
那应该是 hugo 生成的 html 文件中,所有的链接都是根据 所以根据你的服务器环境,修改一下 |
还是不行。。我试了另外一个theme,没有问题。我也很是困惑... anyway,谢谢你,很可惜用不了这个theme! CentOS 7 + Vultr |
能否添加对 gitalk 评论系统的支持? |
config.toml 中文乱码,有设置地方吗? |
找到办法了吗 |
node yaml_to_toml.js ─╯ TypeError: Cannot read property 'map' of undefined |
我也遇到了同样的问题,找了很久,找不到解决办法。有这类错误的,跟 React 相关的很多,可是我不了解它。不知道 JavaScript 和 React 之间的联系 |
把博客从 Hexo 迁移到了 Hugo。主要原因有二:
遂弃用 Hexo。
1. 将 Hexo 的 YAML 转换为 Hugo 的 TOML
Hugo 的配置文件是 TOML 格式的,其生成的 Markdown 文件的 front matter(不知如何翻译)也是 TOML 结构:
而 Hexo 的配置文件是 YAML 格式,其 Markdown 文件的 front matter 如下:
所以直接将 Hexo 的 Markdown 文件复制到 Hugo 中是不行的,必须得转换一下格式。虽然 Hugo 也可以直接在
config.toml
中配置metaDataFormat:"yaml"
,这样 Hugo 就会生成 YAML 结构的 front matter ,但原 Hexo 的 Markdown 文件依旧不能正常的转换,因为date
的格式不一样。在 Hexo 中,文件里面的
date: 2016-09-09 04:11:13
并没有存储时区信息,而是把时区放在了_config.yml
配置文件中。By the way,TOML 是 GitHub 觉得 YAML 不够简洁优雅,所以捣鼓出来的一个东西。既然现在在用 Hugo,就没有理由不用 TOML 代替原来的 YAML。
其实两者之间的转换也很简单,我用 JS 写了一个脚本来将 YAML 转换为 TOML:
先配置好
timezone
src
target
三个参数。然后npm install moment-timezone
安装需要的第三方包,最后node yaml_to_toml.js
即可。2. 图片目录的迁移
本地图片迁移也非常简单。
我之前使用 Hexo 的时候,是将所有图片都放在
source/images/
目录里面的,在 Markdown 文件中引入图片是这样的:
。Hugo 的图片可以直接放在其
static/
目录里面,其路径就是/iamges/image_name.png
,所以我只需要将 Hexo 中的images
目录复制到 Hugo 的static/
目录下即可。3. 主题
看遍了 Hugo 给出的所有主题,都不满意。很多主题都超级简洁,这种风格还是很喜欢的。所以决定自己写一个。
最终 Fork 了 https://github.com/digitalcraftsman/hugo-cactus-theme 这个主题,然后改成了自己想要的样子。
主页
文章页
改后的主题源码:https://github.com/nodejh/hugo-theme-cactus-plus。
4. 部署
由于 Github Pages 国内访问速度慢,所以同时把静态页面部署到了 Github Page 和 Coding Pages。
然后只需要执行
git push all branch
就可以同时向两个仓库 push 代码了。但暂时不这样做。而是在public
目录外创建一个deploy.sh
目录,用来自动部署:接下来再给
deploy.sh
添加可执行权限chmod +x deploy.sh
。然后每次写完东西只需要./deploy.sh 'commit message'
即可。The text was updated successfully, but these errors were encountered: