基于hexo创建博客(Github托管)
Posted geekdanny
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了基于hexo创建博客(Github托管)相关的知识,希望对你有一定的参考价值。
基于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
可以本地预览
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创建博客(Github托管)的主要内容,如果未能解决你的问题,请参考以下文章