混了这么久,一直想拥有本身的博客,经过jekyll和GitHub Pages捣腾出了本身的博客(https://www.ichochy.com)css
Ruby
的开发环境gem install jekyll bundler
安装jekyll
和bundler运行jekyll new myBlog
建立默认的blog
html
文件目录:
-rw-r--r-- 1 mleo staff 35 2 13 15:02 .gitignore -rw-r--r-- 1 mleo staff 398 2 13 15:02 404.html -rw-r--r-- 1 mleo staff 1039 2 13 15:02 Gemfile -rw-r--r-- 1 mleo staff 1686 2 13 15:03 Gemfile.lock -rw-r--r-- 1 mleo staff 1652 2 13 15:02 _config.yml drwxr-xr-x 3 mleo staff 96 2 13 15:02 _posts -rw-r--r-- 1 mleo staff 539 2 13 15:02 about.md -rw-r--r-- 1 mleo staff 175 2 13 15:02 index.md
运行cd myBlog
进入blog
目录,运行bundler exec jelly serve
启动git
MacBook-Pro:myBlog mleo$ bundler exec jekyll serve Configuration file: /Users/mleo/Develop/Coding/myBlog/_config.yml Source: /Users/mleo/Develop/Coding/myBlog Destination: /Users/mleo/Develop/Coding/myBlog/_site Incremental build: disabled. Enable with --incremental Generating... Jekyll Feed: Generating feed for posts done in 0.862 seconds. Auto-regeneration: enabled for '/Users/mleo/Develop/Coding/myBlog' Server address: http://127.0.0.1:4000/ Server running... press ctrl-c to stop.
经过http://127.0.0.1:400
就能够访问blog
了github
以下图:
jekyll目录结构:json
文件/目录 | 描述 |
---|---|
_config.yml |
常量配置信息,网站的基础信息 |
_drafts |
未发布的草稿帖子 |
_includes |
模块化页面,使用: include default.html |
_layouts |
布局模板页面,使用: layout: default |
_posts |
发布的blog,固定格式: YEAR-MONTH-DAY-title.MARKUP 。 |
_data |
文件数据(.yml 、 .yaml 、.json 、.csv 或.tsv 格式) |
_sass |
定义站点使用的样式 |
_site |
Jekyll build 后生成的站点静态文件 |
.jekyll-metadata |
Jekyll build 日志信息 |
index.html 或index.md 其余HTML,Markdown文件 |
将由Jekyll转换,生成首页 |
其余文件/文件夹 | 例如 css 、images 和favicon.ico 文件等 |
经过Gemfile
文件配置 jekyll 主题sass
从Jekyll 3.2开始,jekyll new
使用Gemfile文件来定义网站的主题,使默认目录结构更简单。默认状况下_layouts
,_includes
和_sass
存储在Ruby中。bash
minima 是默认主题,运行 bundle show minima
显示主题文件位置markdown
MacBook-Pro:myBlog mleo$ bundle show minima /Library/Ruby/Gems/2.3.0/gems/minima-2.5.0
自定义站点信息模块化
经过自定义_config.yml
文件,改变 blog 网站信息,布局
常量 | 说明 |
---|---|
title | 标题 |
做者邮箱 | |
description | 网站信息 |
baseurl | 网站路径 |
url | 网站地址,如:https://www.ichochy.com |
twitter_username | 媒体帐号,如:iChochy |
github_username | 媒体帐号,如:iChochy |
注:修改_config.yml
须要重启服务
_post
目录,开始你的创做吧,注意文件的格式必须为YEAR-MONTH-DAY-title.MARKUP
,如:2019-02-13-blog.md
。开始写做吧,直接使用md
语法来书写你的文章
--- layout: post --指定模板 title: "blog" --标题 date: 2019-02-13 15:02:11 +0800 --时间 tags: blog --分类 --- 内容
以下图:
新建一个项目,项目名必须为<username>.github.io
,如:个人用户名为iChochy
,项目名为iChochy.github.io
以下图:
将本地写好的的blog
pull到github
上,在项目设置中打开GitHub Pages
以下图:
master branch
并保存,就完成了部署直接访问项目名(<username>.github.io
)就能够看你blog
了,如:iChochy.github.io
进入域名配置中心,配置域名解析
以下图:
进入github
项目设置,设置本身的域名并保存,就完成了自定义域名设置
以下图:
进入github
项目设置,开启Enforce HTTPS
就完成了
不过,若是是自定义域名,会须要等待几分钟,
github
须要申请证书并部署
邮箱: iChochy@qq.com
网站: https://www.ichochy.com
源文: https://www.ichochy.com/blog/2019/02/13/Jekyll GitHub-Pages部署本身的静态Blog.html