使用 Github 的 Jekyll 搭建个人博客

申请 Github 账号

登录 Github,使用个人邮箱申请一个 Github 帐号

使用 Github 的 Jekyll 搭建个人博客_第1张图片

新建一个 repository

点击右上角的加号


使用 Github 的 Jekyll 搭建个人博客_第2张图片

填写 repository 名称,点击 Create repository


使用 Github 的 Jekyll 搭建个人博客_第3张图片

创建 repository 主页

使用 Github 的 Jekyll 搭建个人博客_第4张图片

选择喜欢的模版

使用 Github 的 Jekyll 搭建个人博客_第5张图片


** 以上内容只是说明如何在 Github 上创建一个 repository 以及创建它的主页 index ,这只是准备工作之一,下面在用 Jekyll 个人博客时会用到 **



使用git创建本地仓库

git 是一个版本控制器,在这里不作详细介绍。我们主要通过它来上传代码,上传内容。

  1. 首先,新建一个放内容的文件夹
 mkdir hongshushu
  1. 把这个文件夹变成 git 可管理的仓库
git init

**(PS:补充创建一个没有父节点的分支gh-pages )
**

git checkout --orphan gh-pages
  1. 在这个仓库中新建几个主机的文件夹,配置文件 * _config.yml *,首页 * index.html *
mkdir _layouts  //存放模板
mkdir _posts     //存放文章内容
  1. 在_layouts中创建模板文件 default.html ,以后的创建的网页都可以用到它




{{ page.title }}
  
  
    {{ content }}
 

  1. 在_posts文件夹中添加博客内容,可以是markdown,html文件
 ---
layout: default
title: 第一次使用 Jekyll
 ---
Jekyll 建博客,简洁美观大方,很棒!
  1. 在根目录下创建首页 index.html
 ---
 layout: default
 title: 我的Blog
 ---
  

{{ page.title }}

  

最新文章

  
        {% for post in site.posts %}       
  • {{ post.date | date_to_string }} {{ post.title }}
  •     {% endfor %}   
  1. 把以上所有操作提交到本地缓存区
git add .
  1. 提交到版本库
git commit -m "ok"
  1. 建立远程仓库连接
git remote add origin [email protected]:zxh578164349/hongshushu.git
  1. 最后,提交
git push -u origin gh-pages

你可能感兴趣的:(使用 Github 的 Jekyll 搭建个人博客)