$ hexo init blog-hexo # 初始化项目,文件夹目录具体可以查看官方文档 INFO Cloning hexo-starter https://github.com/hexojs/hexo-starter.git INFO Install dependencies INFO Start blogging with Hexo! $ cd blog-hexo $ npm install
3、启动
1 2 3
$ hexo g # 生成静态文件,完整命令 hexo generate $ hexo s # 启动本地服务,完整命令 hexo server # 访问网址为: http://localhost:4000/
发布一篇文章试试:
1 2 3
# hexo new <title> $ hexo new test_new_blog # Hexo文件修改时会自动更新,无需重启 Hexo Server。
$ hexo new page categories $ hexo new page tags $ hexo new page archives $ hexo new page about $ hexo new page links
2、进入分类文件夹,并编辑文件
1 2 3 4 5 6 7
$ cd blog-hexo/source/categories $ vim index.md --- title: categories date: 2021-09-18 18:23:51 type: categories ---
注意:分类页面和标签页面需要添加 type。
3、添加页面链接。修改主题_config.yml配置文件,注意不是hexo的配置文件。
1 2 3 4 5 6 7 8 9
$ cd blog-hexo/themes/next/ $ vim _config.yml # 去掉相关注释 menu: home: / || fa fa-home categories: /categories/ || fa fa-th tags: /tags/ || fa fa-tags archives: /archives/ || fa fa-archive about: /about/ || fa fa-user
codeblock: # Code Highlight theme 代码高亮主题 # All available themes: https://theme-next.js.org/highlight/ theme: light:github dark:github-dark prism: light:prism dark:prism-dark # Add copy button on codeblock 在代码块上添加复制按钮 copy_button: enable:true # Available values: default | flat | mac 代码块样式 style:mac
显示文章摘要
官方给出了三种生成摘要的方式
1、手动截断(推荐)
写博客是可是通过手动截断文章,并显示全文阅读链接
1 2 3 4 5 6 7 8 9 10 11 12 13
--- title: Hello World --- Welcome to [Hexo](https://hexo.io/)! This is your very first post. Check [documentation](https://hexo.io/docs/) for more info. If you get any problems when using Hexo, you can find the answer in [troubleshooting](https://hexo.io/docs/troubleshooting.html) or you can ask me on [GitHub](https://github.com/hexojs/hexo/issues).
<!--more-->
## Quick Start ### Create a new post ``` bash $ hexo new "My New Post" ``` More info: [Writing](https://hexo.io/docs/writing.html)
2、通过front-matter添加description
这种方式可以手动设置摘要显示的内容,进入文章详情后不会显示。
1 2 3 4 5
--- title: Hello World description: 这里设置文章的摘要 --- Welcome to [Hexo](https://hexo.io/)! This is your very first post. Check [documentation](https://hexo.io/docs/) for more info. If you get any problems when using Hexo, you can find the answer in [troubleshooting](https://hexo.io/docs/troubleshooting.html) or you can ask me on [GitHub](https://github.com/hexojs/hexo/issues).