基于hexo创建博客(Github托管)

六眼飞鱼酱① 提交于 2019-12-06 05:19:45

基于hexo的博客

搭建步骤

  • 1.依赖文件下载 Node.js

  • 2.Hexo的安装

  • 3.部署到Github

  • 4.Hexo创建博客基本操作

  • 5.Hexo主题皮肤更换

依赖文件Node.js

首先要安装node,npm 前端支持的基础文件

npm包管理,使用cnpm下载速度更快

npm install -g cnpm --registry=https://registry.npm.taobao.org

Hexo框架安装

1.框架安装

cnpm install -g hexo-cli

2.创建一个空文件夹,在文件下创建博客

mkdir blog

3.hexo 的生成,初始化博客

sudo hexo  init

4.博客启动 start

hexo s

可以本地预览

http://localhost:4000

5.编辑新文章

hexo n "文章名称"

hexo g 生成

部署到Github

1.安装github部署的工具

cnpm install --save hexo-deployer-git
vim _config.yml

配置文件

 # Deployment
 ## Docs: https://hexo.io/docs/deployment.html
 deploy:
    type: git
    repo: https://github.com/GeekDengshuo/GeekDengshuo.github.io.git
    branch: master

2.部署命令

hexo d

Hexo创建博客基本操作

// 1.init 
hexo init [folder]     // Initializes a website. If no folder is provided, Hexo will set up the website in the current directory.

// 2.new
hexo new [layout] <title>    
// Creates a new article. If no layout is provided, Hexo will use the default_layout from _config.yml. 
// If the title contains spaces, surround it with quotation marks.


//3.generate
hexo generate

//Option    Description
//-d, --deploy  Deploy after generation finishes
//-w, --watch   Watch file changes
//-b, --bail    Raise an error if any unhandled exception is thrown during generation
//-f, --force   Force regenerate
//-c, --concurrency Maximum number of files to be generated in parallel. Default is infinity


// 4.publish
hexo publish [layout] <filename>

// 5.server
hexo server
// Starts a local server. By default, this is at http://localhost:4000/.
//Option    Description
//-p, --port    Override default port
//-s, --static  Only serve static files
//-l, --log Enable logger. Override logger format.

// 6.deploy
$ hexo deploy  //Deploys your website.

//Option    Description
//-g, --generate    Generate before deployment

// 7.clean
$ hexo clean
//Cleans the cache file (db.json) and generated files (public).

hexo g   // hexo generate

hexo s   // hexo server

hexo d   // hexo deploy

Hexo主题皮肤更换

1.克隆主题

git clone https://github.com/litten/hexo-theme-yilia   下载主题
git clone https://github.com/litten/hexo-theme-yilia.git themes/yilia  // 拷贝到主题目录下

2.修改_config.yml

vim _config.yml
# Extensions
  ## Plugins: https://hexo.io/plugins/
  ## Themes: https://hexo.io/themes/
  theme: yilia

reference

hexo文档

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!