使用Hexo快速搭建自己的博客网站
1.安装基本环境
1、Git : https://git-scm.com/downloads
2、Node.js : https://nodejs.org/en/
2.安装Hexo
npm install -g hexo-cli
3.创建自己本地存放博客的文件夹,在根目录执行如下命令
hexo init luwei # 注:luwei为执行完此命令后项目所在文件夹名
4.创建码云仓库
https://gitee.com/luwei/blog #创建好的仓库地址
5.修改配置文件_config.yml
title: 芦苇浮绿水
subtitle:
description:
keywords:
author: 芦苇
language: en
timezone:
# URL
## If your site is put in a subdirectory, set url as 'http://yoursite.com/child' and root as '/child/'
url: http://yoursite.com
root: /
permalink: :year/:month/:day/:title/
permalink_defaults:
# Directory
source_dir: source
public_dir: public
tag_dir: tags
archive_dir: archives
category_dir: categories
code_dir: downloads/code
i18n_dir: :lang
skip_render:
# Writing
new_post_name: :title.md # File name of new posts
default_layout: post
titlecase: false # Transform title into titlecase
external_link: true # Open external links in new tab
filename_case: 0
render_drafts: false
post_asset_folder: false
relative_link: false
future: true
highlight:
enable: true
line_number: true
auto_detect: false
tab_replace:
# Home page setting
# path: Root path for your blogs index page. (default = '')
# per_page: Posts displayed per page. (0 = disable pagination)
# order_by: Posts order. (Order by date descending by default)
index_generator:
path: ''
per_page: 10
order_by: -date
# Category & Tag
default_category: uncategorized
category_map:
tag_map:
# Date / Time format
## Hexo uses Moment.js to parse and display date
## You can customize the date format as defined in
## http://momentjs.com/docs/#/displaying/format/
date_format: YYYY-MM-DD
time_format: HH:mm:ss
# Pagination
## Set per_page to 0 to disable pagination
per_page: 10
pagination_dir: page
# Extensions
## Plugins: https://hexo.io/plugins/
## Themes: https://hexo.io/themes/
theme: landscape
# Deployment
## Docs: https://hexo.io/docs/deployment.html
deploy:
type: git
repo: https://gitee.com/luwei/blog # 码云的仓库地址
branch: master
message: # 自定义提交消息
6.部署项目到码云
执行如下命令生成静态文件(public文件夹),并提交到码云或码云远程仓库上
hexo d
如果不能提交,请先去码云设置SSH公钥给计算机授权
7.仓库设置开启Pages
8.浏览器输入 http://luwei.gitee.io/blog 访问成功
Hexo的本地命令一般就用到几个:
hexo s -g #在本地运行,调试使用
hexo clean #清除本地缓存
hexo g #拉取博客全部内容
hexo d #将内容推送到git
觉得Hexo默认主题不好看的,我们也可以去官网找个自己喜欢的主题来修改使用:https://hexo.io/themes/ ,下载主题可以用:
git clone https://github.com/litten/主题名称.git themes/title
1.下载的主题会存放在title文件夹下
2.修改_config.yml文件,将theme指定的landscape修改为:下载的主题名称
3.在博客根目录下执行命令,_config.yml文件会新增各种设置,看个人喜好设置即可:
npm i hexo-generator-json-content --save
4.输入命令生成文件并上传
hexo clean
hexo g
hexo d
5.现在就可以编写博客啦,输入命令编写博客,或者编写好markdown文件放进_posts文件夹下即可
hexo new luwei #luwei为博客文件名
ok,完成收工,有兴趣的可以继续研究!
上传**
hexo clean
hexo g
hexo d
5.现在就可以编写博客啦,输入命令编写博客,或者编写好markdown文件放进_posts文件夹下即可
hexo new luwei #luwei为博客文件名