一、先胡扯
本人这次是在linux(ubuntu)下来搭建的,不过其实win下和linux下都是大同小异,都是可以类似比较着看的。
先说说需要的一些工具把,有:git,node.js,github,Hexo。还有一双敢于操作的手。
下面进入操作
二、安装
1、安装git
sudo apt-get install git-core
2、安装G++和curl和安装node.js
sudo apt-get install g++
sudo apt-get install cURL
curl https://raw.github.com/creationix/nvm/master/install.sh | sh
nvm install 0.10或者nvm install stable
3、Hexo
npm install -g hexo-cli
重启终端输入:
nvm use 0.10
初始化hexo:(会在系统目录下生成名为blog的文件夹)
hexo init blog
cd blog
npm install
hexo server
完成以上命令会出现
进入http://localhost:4000/就可以看到个人blog的模型了
三、github建立仓库
仓库名需要是:用户名.github.io
四、配置刚刚建立的blog文件夹下的_config.yml文件
(下面是我配置的,可以作为参考对照)(yml文件格式非常严格,需要空两个空格)
# Hexo Configuration
## Docs: https://hexo.io/docs/configuration.html
## Source: https://github.com/hexojs/hexo/
# Site
title: 林杰_blog
subtitle: 专注web
description:
author: 林杰
language: zh-CN
timezone:
# URL
## If your site is put in a subdirectory, set url as 'http://yoursite.com/child' and root as '/child/'
url: https://github.com/ash-ali/ash-ali.github.io
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: true
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: yilia
# Deployment
## Docs: https://hexo.io/docs/deployment.html
deploy:
type: git
repository: http://github.com/ash-ali/ash-ali.github.io.git
branch: master
server:
port: 4001
compress: true
header: true
××这句很重要××
五、新建文章并添加标签和分类目录
hexo new “新建文章名”
然后进入blog/source/_posts找到web.md(按照下面添加即可)
---
title: title #文章標題
date: 2016-06-01 23:47:44 #文章生成時間
categories: "Hexo教程" #文章分類目錄 可以省略
tags: #文章標籤 可以省略
- 标签1
- 标签2
description: #你對本頁的描述 可以省略
---
六、部署到github中
输入以下命令
hexo clean
hexo g
hexo d
会提示你输入github的用户名和密码
完成后地址栏输入https://ash-ali.github.io/(你只需将你的用户名改一下)就可以看到个人blog了
七、以后写文章需要的步骤
1、hexo new “文章名”
2、进入blog/source/_posts找到md文件写文章
3、部署到github(三步骤:hexo clean,hexo g,hexo d)
八、配置主题
进入blog/themes选择使用中的主题,进入_config.yml文件配置即可
九、更换主题
1.在blog文件下输入命令(yilia为主题名)
git clone https://github.com/litten/hexo-theme-yilia.git themes/yilia
![]()
2.然后在根目录下的_config.yml文件配置修改
3.部署到github(三步骤:hexo clean,hexo g,hexo d)
十、4000端口被占解决
换成4001端口
在根目录文件夹下的_config,yml中加入以下代码
server:
port: 4001
compress: true
header: true
十一、头像,打赏照片URL解决
1、将图片放到主题文件夹下的source文件夹下:如图
2、在主题文件夹下的_config,yml相应模块写图片url
(比如头像是avatar,找到avatar)(其他也都是和这个url一样的类型)
avatar: /webwxgetmsgimg.jpg
附上我主题下的_config.yml配置
# Header
menu:
主页: /
优快云: "http://my.youkuaiyun.com/w_linux"
# SubNav
subnav:
github: "https://github.com/ash-ali"
weibo: "http://weibo.com/5494779824/profile?rightmod=1&wvr=6&mod=personinfo&is_all=1"
#rss: "#"
zhihu: "https://www.zhihu.com/people/xulinjie-89/activities"
qq: "http://shang.qq.com/email/stop/email_stop.html?qq=932834897&sig=d2bf6bb666c927572d6c3d15b484e2a8167596a625ea8d53&tttt=1"
#weixin: "xxlj19980105"
#jianshu: "#"
#douban: "#"
#segmentfault: "#"
#bilibili: "#"
#acfun: "#"
mail: "932834897@qq.com"
#facebook: "#"
#google: "#"
#twitter: "#"
#linkedin: "#"
rss: /atom.xml
# 是否需要修改 root 路径
# 如果您的网站存放在子目录中,例如 http://yoursite.com/blog,
# 请将您的 url 设为 http://yoursite.com/blog 并把 root 设为 /blog/。
root:
# Content
# 文章太长,截断按钮文字
excerpt_link: more
# 文章卡片右下角常驻链接,不需要请设置为false
show_all_link: '展开全文'
# 数学公式
mathjax: false
# 是否在新窗口打开链接
open_in_new: false
# 打赏
# 打赏type设定:0-关闭打赏; 1-文章对应的md文件里有reward:true属性,才有打赏; 2-所有文章均有打赏
reward_type: 2
# 打赏wording
reward_wording: '谢谢打赏哦'
# 支付宝二维码图片地址,跟你设置头像的方式一样。比如:/assets/img/alipay.jpg
alipay:
# 微信二维码图片地址
weixin: /getmoney.jpg
# 目录
# 目录设定:0-不显示目录; 1-文章对应的md文件里有toc:true属性,才有目录; 2-所有文章均显示目录
toc: 1
# 根据自己的习惯来设置,如果你的目录标题习惯有标号,置为true即可隐藏hexo重复的序号;否则置为false
toc_hide_index: true
# 目录为空时的提示
toc_empty_wording: '目录,不存在的…'
# 是否有快速回到顶部的按钮
top: true
# Miscellaneous
baidu_analytics: ''
google_analytics: ''
favicon: /favicon.png
#你的头像url
avatar: /webwxgetmsgimg.jpg
#是否开启分享
share_jia: true
#评论:1、多说;2、网易云跟帖;3、畅言;4、Disqus;5、Gitment
#不需要使用某项,直接设置值为false,或注释掉
#具体请参考wiki:https://github.com/litten/hexo-theme-yilia/wiki/
#1、多说
duoshuo: false
#2、网易云跟帖
wangyiyun: false
#3、畅言
changyan_appid: false
changyan_conf: false
#4、Disqus 在hexo根目录的config里也有disqus_shortname字段,优先使用yilia的
disqus: false
#5、Gitment
gitment_owner: false #你的 GitHub ID
gitment_repo: '' #存储评论的 repo
gitment_oauth:
client_id: '' #client ID
client_secret: '' #client secret
# 样式定制 - 一般不需要修改,除非有很强的定制欲望…
style:
# 头像上面的背景颜色
header: '#4d4d4d'
# 右滑板块背景
slider: 'linear-gradient(200deg,#a0cfe4,#e8c37e)'
# slider的设置
slider:
# 是否默认展开tags板块
showTags: true
# 智能菜单
# 如不需要,将该对应项置为false
# 比如
#smart_menu:
# friends: false
smart_menu:
innerArchive: '所有文章'
friends: '友链'
aboutme: '关于我'
friends:
友情链接1: http://localhost:4000/
友情链接2: http://localhost:4000/
友情链接3: http://localhost:4000/
友情链接4: http://localhost:4000/
友情链接5: http://localhost:4000/
友情链接6: http://localhost:4000/
aboutme: 本人普通本科大二学生,熟悉HTML、CSS、C、C++、WP框架、Bootstrap框架,了解Linux(乌班图)操作系统、github各种搭建博客,ThinkPhp。
本人blog:https://ash-ali.github.io/
1979

被折叠的 条评论
为什么被折叠?



