博客框架選擇以及發布博客

jopen 9年前發布 | 13K 次閱讀 博客

框架選擇

隨著web技術的不斷發展,可以產生靜態博客的框架也越來越多,比如流行的 jekyiioctopressHexoHugo ,以及middleman,Pelican,Metalsmith。小G比較過集中常用的框架,比如github自帶的jekyii,還有hugo。最后選擇了Hexo。

  1. Github Pages默認使用jekyii作為建立靜態博客的framework,但是對于jekyii,小G覺得一方面jekyii安裝太過復雜,然后相對于其他的framework比較慢,所以就試了一下就沒有再用了
  2. Hugo聽說輕量級以及速度很快,嘗試了一下果然很快。然后跑去他的官網看文檔,寫的是很清楚。有一個問題是它的不同的theme有不用的configuration,所以在theme之間切換不是很容易,而且由于是輕量級的所以有很多東西需要自己配置,上手有點慢。
  3. 第一次用到hexo的時候覺得這個框架非常容易上手,一共就五個命令:hexo n, hexo clean, hexo g, hexo s, hexo d,從開發到配置到發布全部搞定。而且theme之間的切換也非常容易,而且大部分的configuration都已經集成,很容易使用。
  4. 這些做靜態博客的framework都比較靈活,可以不費很多時間和精力從一個遷移到另一個,所以小G認為如果對這感興趣可以把主流的framework都試一遍,找到自己最好的。小G本人覺得最好用的是hexo,所以決定使用這個framework。
  5. </ol>

    發布博客

    才開始寫博客,所以小G打算使用gitpage來host這個靜態的網站。

    建立github page 倉庫

    在登錄github后,新建一個倉庫: [username].github.io。

    這個倉庫每個github賬戶只能建立一個,不過這是免費的,已經很不錯了。

    Hexo安裝

    首先是安裝hexo,你在電腦上需要安裝nodejs和git。然后就可以安裝hexo:

    $ npm install -g hexo-cli
    </div>

    安裝完之后在command line 里面測試hexo是否安裝好,直接輸入hexo看是否會有如下信息:

    sage: hexo <command>

    Commands: clean Removed generated files and cache. config Get or set configurations. deploy Deploy your website. generate Generate static files. help Get help on a command. init Create a new Hexo folder. list List the information of the site migrate Migrate your site from other system to Hexo. new Create a new post. publish Moves a draft post from _drafts to _posts folder. render Render files with renderer plugins. server Start the server. version Display version information.

    Global Options: --config Specify config file instead of using _config.yml --cwd Specify the CWD --debug Display all verbose messages in the terminal --draft Display draft posts --safe Disable all plugins and scripts --silent Hide output on console

    For more help, you can use 'hexo help [command]' for the detailed information or you can check the docs: http://hexo.io/docs/</pre></div> </div>

    Hexo配置

    然后就是Hexo的配置了,首先是新建文件夾:

    $ hexo init <folder>
    $ cd <folder>
    $ npm install
    </div>

    然后文件夾里面的路徑應該就如下所示:

    .
    ├── _config.yml
    ├── package.json
    ├── scaffolds
    ├── source
    |   ├── _drafts
    |   └── _posts
    └── themes
    </div>