使用GitHub.io当作自己的博客网站
2018年07月02日 09:16:24 jackycheng86 阅读数 9383更多
作为程序猿很多时候我们都都会自己写一些博客,通常我们都是在国内的博客网站上写,比如csdn、iteye、cnblogs等等博客网站。这些博客网站也提供了很好的功能,但是相对来说个性化方面就要差一些了。
今天我将介绍另一种写博客的方式,用github来写博客并且将博客发布到github上是不是很洋气!!
github提供了一个功能叫github.io,用官网的一句话来形容 Websites for you and your projects.
如果要使用github.io首先也是需要在github上创建一个repository,这个repository的名字还有要求必须是username.github.io,比如我的就是jackycheng86.github.io。
创建好仓库就很简单了,只需要git clone https://github.com/username/username.github.io。
然后再在这个目录中编写静态html内容就行了
cd username.github.io
echo “Hello World” > index.html
git add –all
git commit -m “Initial commit”
git push -u origin master
这样一个最基本的github.io博客页面就做好了。
当然这样是远远不够的,那么github给我们推荐了一些办法来构建静态的博客内容,github推荐的是Jekyll这个静态网站构建工具,那么下一步我们就来看看怎么通过Jekyll构建静态网站。
首先在Jekyll官网Jekyll,官网上写得很清楚Transform your plain text into static websites and blogs.将纯文本内容构建为静态网页和博客
Jekyll安装
首先我们看看官网对Jekyll的安装需求
Before you start, make sure your system has the following:
- Ruby version 2.2.5 or above, including all development headers (ruby installation can be checked by running ruby -v)
- RubyGems (which you can check by running gem -v)
- GCC and Make (in case your system doesn’t have them installed, which you can check by running gcc -v,g++ -v and make -v in your system’s command line interface)
从上面需求来看Jekyll对windows的支持不太好,官方并没有提供对windows的支持,只有其他的一些办法来在windows上安装Jekyll。
笔者的系统环境
OS: Gentoo
因此在系统安装过程中已经安装ruby、gcc、make等包,如果没有的话自行安装
安装完以后
jacky@gentoo ~ $ sudo gem install bundler jekyll
主要这里必须要使用root权限来进行安装,在安装完后运行
jacky@gentoo ~/github/jackycheng86.github.io $ bundle exec jekyll serve
Could not find i18n-0.9.1 in any of the sources
Run `bundle install` to install missing gems.
可能你会出现这个情况,那么就按照提示操作就是了
最后得到以下结果
Thank you for installing html-pipeline!
You must bundle Filter gem dependencies.
See html-pipeline README.md for more details.
https://github.com/jch/html-pipeline#dependencies
到此为止我们就完成了基本的Jekyll的安装配置啦
要运行也很简单
jacky@gentoo ~ $ cd github/
AdminLTE/ jackycheng86.github.io/ spring/
jacky@gentoo ~ $ cd github/jackycheng86.github.io/
jacky@gentoo ~/github/jackycheng86.github.io $ bundle exec jekyll serve
Configuration file: /home/jacky/github/jackycheng86.github.io/_config.yml
Source: /home/jacky/github/jackycheng86.github.io
Destination: /home/jacky/github/jackycheng86.github.io/_site
Incremental build: disabled. Enable with --incremental
Generating...
done in 2.012 seconds.
Auto-regeneration: enabled for '/home/jacky/github/jackycheng86.github.io'
Server address: http://127.0.0.1:4000
Server running... press ctrl-c to stop.
这时候Jekyll就已经运行起来了,通过localhost:4000端口就能看到内容,如果我们修改了静态html内容只需要将修改好的内容push到github我们在github.io上的页面也就得到了更新。
有了Jekyll我们就可以去找很多Jekyll的模板来让我们的博客看起来更漂亮了传送门
相关文章
- 从github拉取项目到myeclipse本地
- Github Pages + Jekyll 独立博客一小时快速搭建&上线指南
- ocr 识别 github 源码
- 【问题解决方案】GitHub仓库重构之将某个或某些文件夹移动到其他文件夹内
- 搭建登录系统的github地址
- 【问题解决方案】git/github本地和远程仓库的重命名
- [Github] Create a GitHub PR Template
- 《安富莱嵌入式周报》第307期:开源智能制冷板,Keil MDK6发布时间,编程助手Github Copilot X,Matlab2023,高品质电容式麦DIY
- 如何在 SAP UI5 应用里安全存储一些敏感的数据,避免被上传到 Github 去的风险试读版
- SAP托管在Github上的ABAP编程规范
- ABAP开发的Github issue备份工具
- cannot push the change done in WebIDE to github
- 什么是Github的元数据metadata以及如何备份github上的数据
- 如何在Github里创建organization和代码仓库
- github pages帮助如何创建个人博客
- 通过GitHub和Hexo搭建个人博客
- 【Github教程】史上最全github用法:github入门到精通
- golangWeb框架---github.com/gin-gonic/gin学习七(重定向、中间件Goroutines、http自定义配置)
- 【基础知识】11、github上传本地代码
- [Git & GitHub] eclipse中使用Egit 撤销commit提交