初始化站点
运行hexo init "folder_test"
命令即可初始化一个hexo静态网站,运行日志如下
INFO Cloning hexo-starter to ~/Desktop/temp/test
Cloning into '/Users/xiangpeng/Desktop/temp/test'...
remote: Enumerating objects: 3, done.
remote: Counting objects: 100% (3/3), done.
remote: Compressing objects: 100% (3/3), done.
remote: Total 71 (delta 0), reused 0 (delta 0), pack-reused 68
Unpacking objects: 100% (71/71), done.
Submodule 'themes/landscape' (https://github.com/hexojs/hexo-theme-landscape.git) registered for path 'themes/landscape'
Cloning into '/Users/xiangpeng/Desktop/temp/test/themes/landscape'...
remote: Enumerating objects: 8, done.
remote: Counting objects: 100% (8/8), done.
remote: Compressing objects: 100% (8/8), done.
remote: Total 885 (delta 1), reused 5 (delta 0), pack-reused 877
Receiving objects: 100% (885/885), 2.55 MiB | 16.00 KiB/s, done.
Resolving deltas: 100% (464/464), done.
Submodule path 'themes/landscape': checked out '73a23c51f8487cfcd7c6deec96ccc7543960d350'
INFO Install dependencies
yarn install v1.13.0
info No lockfile found.
[1/4] Resolving packages...
warning hexo > [email protected]: no longer maintained
[2/4] Fetching packages...
[3/4] Linking dependencies...
[4/4] Building fresh packages...
success Saved lockfile.
✨ Done in 23.58s.
INFO Start blogging with Hexo!
站点目录结构
在生成的站点目录中有如下文件及子文件夹
|-- _config.yml # 网站的主配置文件
|-- node_modules # nodejs 依赖包的本地安装目录
|-- package.json # npm(nodejs package manager) 依赖的配置文件
|-- scaffolds # 网站页面模板文件存放目录
|-- public # 生成的静态网站存放目录(初始话时没有此目录,只有在运行 hexo generate时才会生成)
|-- source # 文章存放目录
|-- yarn.lock # yarn(一个与npm相似的包管理攻击) 依赖的配置文件
生成页面和启动预览
我们在生成的站点的根目录运行hexo g
即可生成静态页面,这时运行hexo s
可在本地打开一个预览web服务器来查看站点的效果站点的默认站点为http://localhost:4000。
cd "folder_test" # 进入测试目录
hexo g # 同 hexo generate 生成hexo静态页面(public 目录下)
hexo s # 同 hexo server 启动hexo自带的web服务器预览页面