hexo学习记录


概述

  • Hexo 是一个快速、简洁且高效的博客框架。Hexo 使用 Markdown(或其他标记语言)解析文章,在几秒内,即可利用靓丽的主题生成静态网页。

基本指令

  • Usage: hexo < command >

  • Commands:

    • clean
      • Remove generated files and cache.
      • 删除生成文件与缓存(public文件夹等)
    • config
      • Get or set configurations. 获取或设置配置
      • eg: hexo config theme icarus 将主题设置为icarus
      • (当然也可以直接改_config.yml)
    • deploy
      • Deploy your website.
      • 部署到网站上
    • generate
      • Generate static files.
      • 生成静态文件
    • help
      • Get help on a command. 获取帮助
      • eg: hexo help config 获取config的帮助
      • eg: hexo help 获取所有指令的帮助
    • init
      • Create a new Hexo folder.
      • 创建一个新的Hexo文件夹
    • list
      • List the information of the site.
      • 列出站点信息
    • migrate
      • Migrate your site from other system to Hexo.
      • 从其他系统迁移你的站点到Hexo
    • new
      • Create a new post/draft. 创建新文章、草稿
      • eg hexo new post article
      • 创建一个名为article的文章,布局为post
    • publish
      • Moves a draft post from _drafts to _posts folder.
      • 将草稿移动到_posts文件夹
    • render
      • Render files with renderer plugins.
      • 使用渲染器插件渲染文件
    • server
      • Start the server.
      • 启动服务器,默认losthost:4000
    • version
      • Display version information.
      • 显示版本信息
  • Global Options(全局选项):

    • –config
      • Specify config file instead of using _config.yml
      • 指定配置文件
    • –cwd
      • Specify the CWD
      • 指定命令行
    • –debug
      • Display all verbose messages in the terminal
      • debug模式输出所有信息
    • –draft
      • Display draft posts
      • 展示所有草稿
    • –safe
      • Disable all plugins and scripts
      • 禁用所有插件和脚本
    • –silent
      • Hide output on console
      • 隐藏输出

基于hexo的blog搭建

  • 基于hexo的blog搭建,其实对我这种没咋写前端的人还是有点痛苦(论熟悉javascript的重要性),不过有现成的模板,cv后改改就行。

前置条件

  1. 安装node.js
  2. 安装git
  3. 安装hexo
    npm install -g hexo-cli 或者 npm install hexo

建立blog

  1. 建立blog文件夹
    hexo init < filename >
    cd < filename >
    npm install
  2. 基于自己的需要修改配置
    一般是修改_config.yml,或者用hexo config
    修改参见hexo官网

文章编写

  1. 新建文章
    hexo new post < title >
    会在source/_posts下生成一个md文件,可以直接用markdown语法编写
  2. 写草稿
    hexo new draft < title >
    会在source/_drafts下生成一个md文件,可以直接用markdown语法编写
  3. 发布草稿
    hexo publish < title >
    会将草稿移动到source/_posts下

常见问题

  1. 换主题
    更改theme,然后在theme文件夹下的主题中做进一步修改,参见hexo官网以及主题文档。
  2. 换样式
    基于css等进行修改
  3. 换域名
    修改_config.yml中的url,记得在自己的服务部署处进行更新。
  4. github自动化部署
    用github action,参见hexo官网
  5. 各种花活
    自行搜索.jpg

作者

Norton-Lin

发布于

2023-06-26

更新于

2024-09-01

许可协议

评论