• 使用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:

    1. Ruby version 2.2.5 or above, including all development headers (ruby installation can be checked by running ruby -v)
    2. RubyGems (which you can check by running gem -v)
    3. 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的模板来让我们的博客看起来更漂亮了传送门

  • 相关阅读:
    本地通知
    常用颜色RGB、灰度值
    AFNetworkingErrorDomain 错误解决方法
    给iOS开发新手送点福利,简述UIPikerView的属性和用法
    给iOS开发新手送点福利,简述UIImagePickerController的属性和用法
    给iOS开发新手送点福利,简述UIDatePicker的用法
    iOS线程开发小结
    给iOS开发新手送点福利,简述文本属性Attributes的用法
    给iOS开发新手送点福利,简述UIScrollView的属性和用法
    给iOS开发新手送点福利,简述UITableView的属性和用法
  • 原文地址:https://www.cnblogs.com/grj001/p/12223422.html
Copyright © 2020-2023  润新知