{"id":336,"date":"2017-02-12T20:35:45","date_gmt":"2017-02-12T12:35:45","guid":{"rendered":"http:\/\/www.thinkmesh.net\/?p=336"},"modified":"2017-02-12T21:09:08","modified_gmt":"2017-02-12T13:09:08","slug":"%e4%bd%bf%e7%94%a8hugo%e6%90%ad%e5%bb%ba%e4%b8%aa%e4%ba%ba%e5%8d%9a%e5%ae%a2%e7%ab%99%e7%82%b9","status":"publish","type":"post","link":"http:\/\/www.thinkmesh.net\/?p=336","title":{"rendered":"\u4f7f\u7528Hugo\u642d\u5efa\u4e2a\u4eba\u535a\u5ba2\u7ad9\u70b9"},"content":{"rendered":"<div class=\"alert alert-success\" role=\"alert\">\u8be5\u6587\u6574\u7406\u81ea\u7f51\u7edc\uff0c\u66f4\u591a\u8be6\u7ec6\u5185\u5bb9\u89c1<a href=\"http:\/\/blog.coderzh.com\/2015\/08\/29\/hugo\/\">\u8fd9\u91cc<\/a>\u3002<\/div>\n<p>Hugo\u662f\u4e00\u4e2a\u7528Go\u8bed\u8a00\u7f16\u5199\u7684\u9759\u6001\u7f51\u7ad9\u751f\u6210\u5668\uff0c\u5b83\u4f7f\u7528\u8d77\u6765\u975e\u5e38\u7b80\u5355\uff0c\u76f8\u5bf9\u4e8eJekyll\u590d\u6742\u7684\u5b89\u88c5\u8bbe\u7f6e\u6765\u8bf4\uff0cHugo\u4ec5\u9700\u8981\u4e00\u4e2a\u4e8c\u8fdb\u5236\u6587\u4ef6hugo(hugo.exe)\u5373\u53ef\u8f7b\u677e\u7528\u4e8e\u672c\u5730\u8c03\u8bd5\u548c\u751f\u6210\u9759\u6001\u9875\u9762\u3002Hugo\u751f\u6210\u9759\u6001\u9875\u9762\u7684\u6548\u7387\u5f88\u9ad8\uff0c\u5bf9\u4e8e260\u591a\u7bc7\u535a\u5ba2\u6587\u7ae0\u751f\u6210\u51e0\u4e4e\u662f\u77ac\u95f4\u5b8c\u6210\u7684\uff0c\u800c\u4e4b\u524d\u7528Jekyll\u9700\u8981\u7b49\u5f8510\u79d2\u5de6\u53f3\u3002Hugo\u81ea\u5e26watch\u7684\u8c03\u8bd5\u6a21\u5f0f\uff0c\u53ef\u4ee5\u5728\u4fee\u6539MarkDown\u6587\u7ae0\u4e4b\u540e\u5207\u6362\u5230\u6d4f\u89c8\u5668\uff0c\u9875\u9762\u4f1a\u68c0\u6d4b\u5230\u66f4\u65b0\u5e76\u4e14\u81ea\u52a8\u5237\u65b0\uff0c\u5448\u73b0\u51fa\u6700\u7ec8\u6548\u679c\uff0c\u80fd\u6781\u5927\u7684\u63d0\u9ad8\u535a\u5ba2\u4e66\u5199\u6548\u7387\u3002\u518d\u52a0\u4e0aHugo\u662f\u4f7f\u7528Go\u8bed\u8a00\u7f16\u5199\uff0c\u5df2\u7ecf\u6ca1\u6709\u4efb\u4f55\u7406\u7531\u4e0d\u4f7f\u7528Hugo\u4f5c\u4e3a\u4e2a\u4eba\u535a\u5ba2\u7ad9\u70b9\u751f\u6210\u5668\u4e86\u3002<\/p>\n<h2>GitHub\u6258\u7ba1<\/h2>\n<p>\u5bf9\u4e8e\u6ca1\u6709\u8d2d\u4e70\u7f51\u7ad9\u7a7a\u95f4\u7684\u7528\u6237\uff0c\u53ef\u4ee5\u501f\u52a9GitHub\u5efa\u7acb\u81ea\u5df1\u7684\u4e2a\u4eba\u4e3b\u9875\u3002\u4f60\u53ea\u9700\u8981\u5728GitHub\u4e0a\u521b\u5efa\u4e00\u4e2a\u9879\u76ee\uff0c\u7136\u540e\u5c06\u751f\u6210\u51fa\u6765\u7684\u9759\u6001\u9875\u9762\u6587\u4ef6push\u5230\u8fd9\u4e2a\u9879\u76ee\u7684gh-pages\u5206\u652f\uff0c\u4fdd\u8bc1\u6839\u76ee\u5f55\u6709\u4e00\u4e2aindex.html\u6587\u4ef6\u5373\u53ef\u3002\u8fd9\u6837\uff0c\u4e00\u4e2a\u514d\u8d39\u3001\u65e0\u9650\u6d41\u91cf\u7684\u535a\u5ba2\u7cfb\u7edf\u5c31\u642d\u5efa\u5b8c\u6210\u4e86\u3002\u540c\u65f6\uff0c\u901a\u8fc7github\u4f60\u53ef\u4ee5\u65b9\u4fbf\u5bf9\u535a\u5ba2\u6587\u7ae0\u8fdb\u884c\u7ba1\u7406\u548c\u8ffd\u8e2a\u3002<\/p>\n<h2>Hugo\u7b80\u4ecb<\/h2>\n<p>Hugo\u662f\u4ec0\u4e48\uff1f\u80fd\u505a\u4ec0\u4e48\uff1f\u4e0b\u9762\u7ed9\u51fa\u7b80\u5355\u7684\u603b\u7ed3\uff1a<\/p>\n<ul>\n<li>Hugo\u53ea\u6709\u4e00\u4e2a\u4e8c\u8fdb\u5236\u6587\u4ef6\uff08\u6bd4\u5982Windows\u91cc\u53ea\u662f\u4e00\u4e2ahugo.exe\uff09<\/li>\n<li>Hugo\u53ef\u4ee5\u5c06\u4f60\u5199\u597d\u7684MarkDown\u683c\u5f0f\u7684\u6587\u7ae0\u81ea\u52a8\u8f6c\u6362\u4e3a\u9759\u6001\u7684\u7f51\u9875\u3002<\/li>\n<li>Hugo\u5185\u7f6eweb\u670d\u52a1\u5668\uff0c\u53ef\u4ee5\u65b9\u4fbf\u7684\u7528\u4e8e\u672c\u5730\u8c03\u8bd5\u3002<\/li>\n<\/ul>\n<p>Hugo\u5b98\u65b9\u4e3b\u9875\u5728<a href=\"https:\/\/gohugo.io\/\">\u8fd9\u91cc<\/a>\uff0cGitHub\u4e0a\u6709\u5176\u4ee3\u7801\u6258\u7ba1\uff0c\u53ef\u4ee5\u770b<a href=\"https:\/\/github.com\/spf13\/hugo\">\u8fd9\u91cc<\/a>\u3002Hugo\u7684\u5b89\u88c5\u65b9\u5f0f\u6709\u4e24\u79cd\uff0c\u4e00\u79cd\u662f\u76f4\u63a5\u4e0b\u8f7d\u7f16\u8bd1\u597d\u7684Hugo\u4e8c\u8fdb\u5236\u6587\u4ef6\u3002\u5982\u679c\u53ea\u662f\u4f7f\u7528Hugo\u63a8\u8350\u7528\u8fd9\u79cd\u65b9\u5f0f\u3002\u53e6\u4e00\u79cd\u65b9\u5f0f\u662f\u83b7\u53d6Hugo\u7684\u6e90\u7801\uff0c\u81ea\u5df1\u7f16\u8bd1\u3002\u7531\u4e8e\u5404\u79cd\u4e0d\u53ef\u9884\u6599\u7684\u7f51\u7edc\u95ee\u9898\uff0c\u7b2c\u4e8c\u79cd\u65b9\u5f0f\u4e0d\u662f\u90a3\u4e48\u8f7b\u6613\u80fd\u6210\u529f\u3002\u5982\u679c\u60f3\u4e0b\u8f7dHugo\u4e8c\u8fdb\u5236\u6587\u4ef6\uff0c\u53ef\u4ee5\u770b<a href=\"https:\/\/github.com\/spf13\/hugo\/releases\">\u8fd9\u91cc<\/a>\uff0c\u53ef\u4ee5\u5f97\u5230hugo\u6216\u8005hugo.exe\u7684\u7a0b\u5e8f\u3002<\/p>\n<h2>Hugo\u751f\u6210\u4e3b\u9875<\/h2>\n<p>\u63a5\u4e0b\u6765\uff0c\u9010\u6b65\u751f\u6210\u81ea\u5df1\u7684\u7ad9\u70b9\uff1a<br \/>\n<strong><u>1.\u4ea7\u751f\u65b0\u7ad9\u70b9<\/u><\/strong><\/p>\n<pre class=\"prettyprint linenums\" >\r\n$ hugo new site mysite\r\n<\/pre>\n<p>\u4f1a\u4ea7\u751f\u5982\u4e0b\u7684\u76ee\u5f55\u7ed3\u6784\uff1a<\/p>\n<pre class=\"prettyprint linenums\" >\r\n  \u25b8 archetypes\/\r\n  \u25b8 content\/\r\n  \u25b8 layouts\/\r\n  \u25b8 static\/\r\n    config.toml\r\n<\/pre>\n<p>\u5176\u4e2d\uff0cconfig.toml\u662f\u7f51\u7ad9\u7684\u914d\u7f6e\u6587\u4ef6\uff0c\u8fd9\u662f\u4e00\u4e2aTOML\u6587\u4ef6\uff0c\u5168\u79f0\u662fTom\u2019s Obvious, Minimal Language\uff0c\u8fd9\u662f\u5b83\u7684\u4f5c\u8005GitHub\u8054\u5408\u521b\u59cb\u4ebaTom Preston-Werner \u89c9\u5f97YAML\u4e0d\u591f\u4f18\u96c5\uff0c\u6363\u9f13\u51fa\u6765\u7684\u4e00\u4e2a\u65b0\u683c\u5f0f\u3002\u5982\u679c\u4f60\u4e0d\u559c\u6b22\u8fd9\u79cd\u683c\u5f0f\uff0c\u4f60\u53ef\u4ee5\u5c06config.toml\u66ff\u6362\u4e3aYAML\u683c\u5f0f\u7684config.yaml\uff0c\u6216\u8005json\u683c\u5f0f\u7684config.json\u3002hugo\u90fd\u652f\u6301\u3002content\u76ee\u5f55\u91cc\u653e\u7684\u662f\u4f60\u5199\u7684markdown\u6587\u7ae0\uff0clayouts\u76ee\u5f55\u91cc\u653e\u7684\u662f\u7f51\u7ad9\u7684\u6a21\u677f\u6587\u4ef6\uff0cstatic\u76ee\u5f55\u91cc\u653e\u7684\u662f\u4e00\u4e9b\u56fe\u7247\u3001css\u3001js\u7b49\u8d44\u6e90\u3002<br \/>\n<strong><u>2.\u8fdb\u5165\u65b0\u521b\u5efa\u7684\u7ad9\u70b9\u76ee\u5f55<\/u><\/strong><\/p>\n<pre class=\"prettyprint linenums\" >\r\n$ cd mysite\r\n<\/pre>\n<p><strong><u>3.\u521b\u5efa\u4e00\u4e2a\u9875\u9762<\/u><\/strong><\/p>\n<pre class=\"prettyprint linenums\" >\r\n$ hugo new about.md\r\n<\/pre>\n<p>\u5982\u679c\u662f\u535a\u5ba2\u65e5\u5fd7\uff0c\u6700\u597d\u5c06md\u6587\u4ef6\u653e\u5728content\u7684post\u76ee\u5f55\u91cc\u3002<\/p>\n<pre class=\"prettyprint linenums\" >\r\n$ hugo new post\/first.md\r\n<\/pre>\n<p>\u6267\u884c\u5b8c\u540e\uff0c\u4f1a\u5728content\/post\u76ee\u5f55\u81ea\u52a8\u751f\u6210\u4e00\u4e2aMarkDown\u683c\u5f0f\u7684first.md\u6587\u4ef6\uff1a<\/p>\n<pre class=\"prettyprint linenums\" >\r\n+++\r\ndate = &quot;2015-01-08T08:36:54-07:00&quot;\r\ndraft = true\r\ntitle = &quot;first&quot;\r\n \r\n+++\r\n<\/pre>\n<p>+++\u53ef\u4ee5\u66ff\u6362\u4e3aJekyll\u4e00\u6837\u7684&#8212;\uff0c\u91cc\u9762\u7684\u5185\u5bb9\u662f\u8fd9\u7bc7\u6587\u7ae0\u7684\u4e00\u4e9b\u4fe1\u606f\u3002\u4e0b\u9762\u5c31\u53ef\u4ee5\u5f00\u59cb\u5199\u4f60\u7684\u6587\u7ae0\u5185\u5bb9\uff0c\u6bd4\u5982\uff1a<\/p>\n<pre class=\"prettyprint linenums\" >\r\n+++\r\ndate = &quot;2015-01-08T08:36:54-07:00&quot;\r\ndraft = true\r\ntitle = &quot;first&quot;\r\n \r\n+++\r\n\r\n### Hello Hugo\r\n\r\n 1. aaa\r\n 1. bbb\r\n 1. ccc\r\n<\/pre>\n<p>\u597d\u4e86\uff0c\u521a\u624d\u7684about.md\u4e5f\u6709\u5185\u5bb9\uff0c\u8be5\u770b\u770b\u6700\u540e\u7684\u6548\u679c\u4e86\u3002\u7136\u540e\u4f60\u5c41\u98a0\u5c41\u98a0\u7684\u4f7f\u7528hugo server\u542f\u52a8\uff0c\u6253\u5f00\u6d4f\u89c8\u5668\u91cc\u4e00\u770b\uff0c\u53d1\u73b0\u4ec0\u4e48\u90fd\u6ca1\u6709\uff01\u80bf\u4e48\u4e86\uff01\u8fd9\u662fHugo\u5bf9\u521d\u5b66\u8005\u975e\u5e38\u4e0d\u53cb\u597d\u7684\u5730\u65b9\uff0c\u9ed8\u8ba4\u751f\u6210\u7684\u7f51\u7ad9\u662f\u6ca1\u6709\u4efb\u4f55\u76ae\u80a4\u6a21\u677f\u7684\u3002\u4e3a\u4e86\u770b\u770b\u7b2c\u4e00\u4e2a\u5199\u7684\u793a\u4f8b\uff0c\u8fd8\u5f97\u53bbGithub\u4e0a\u628a\u4e00\u4e2a\u7f51\u9875\u6a21\u677f\u4e0b\u8f7d\u4e0b\u6765\u3002\u5982\u679c\u4f60\u7f51\u7edc\u591f\u597d\uff0c\u7f51\u901f\u591f\u5feb\uff0c\u4f60\u53ef\u4ee5\u5728\u521a\u624d\u7684\u76ee\u5f55\u5c06Hugo\u5b98\u65b9\u7684\u6240\u6709\u6a21\u677f\u90fd\u4e0b\u8f7d\u4e0b\u6765\uff1a<\/p>\n<pre class=\"prettyprint linenums\" >\r\n$ git clone --recursive https:\/\/github.com\/spf13\/hugoThemes themes\r\n<\/pre>\n<p>\u6211\u5c1d\u8bd5\u8fc7\uff0c\u4e5f\u5931\u8d25\u8fc7\uff0c\u4e14\u4ece\u672a\u6210\u529f\u4e00\u6b21\u6027\u5c06\u6240\u6709\u7684\u6a21\u677f\u4e0b\u8f7d\u4e0b\u6765\u3002\u6240\u4ee5\uff0c\u6211\u4eec\u8fd8\u662f\u8001\u8001\u5b9e\u5b9e\u53ea\u4e0b\u8f7d\u5176\u4e2d\u4e00\u4e2a\u6a21\u677f\u6765\u770b\u770b\u6548\u679c\u5427\uff1a<\/p>\n<pre class=\"prettyprint linenums\" >\r\n$ cd themes\r\n$ git clone https:\/\/github.com\/spf13\/hyde.git\r\n<\/pre>\n<p><strong><u>4.\u542f\u52a8\u672c\u5730\u8c03\u8bd5<\/u><\/strong><\/p>\n<pre class=\"prettyprint linenums\" >\r\n$ hugo server --theme=hyde --buildDrafts --watch\r\n<\/pre>\n<p>\u6d4f\u89c8\u5668\u91cc\u6253\u5f00\uff1ahttp:\/\/127.0.0.1:1313\uff0c\u7b49\u5f85\u7247\u523b\u5c31\u80fd\u770b\u5230\u9875\u9762\u4e86\u3002\u5728\u4e0a\u9762\u7684\u547d\u4ee4\u4e2d\uff0c\u2013watch\u6216\u8005-w \u9009\u9879\u6253\u5f00\u7684\u8bdd\uff0c\u5c06\u4f1a\u76d1\u63a7\u5230\u6587\u7ae0\u7684\u6539\u52a8\u4ece\u800c\u81ea\u52a8\u53bb\u5237\u65b0\u6d4f\u89c8\u5668\uff0c\u4e0d\u9700\u8981\u81ea\u5df1\u624b\u5de5\u53bb\u5237\u65b0\u6d4f\u89c8\u5668\uff0c\u975e\u5e38\u65b9\u4fbf\u3002<br \/>\n\u5982\u679c\u4f60\u770b\u4e86\u4e0a\u9762\u7684\u8bf4\u660e\u5df2\u7ecf\u6709\u51b2\u52a8\u53bb\u8bd5\u4e00\u8bd5Hugo\u4e86\uff0c\u6211\u7684\u76ee\u7684\u4e5f\u7b97\u8fbe\u5230\u4e86\uff0c\u63a5\u4e0b\u6765\u4f60\u9700\u8981\u7684\u53ea\u662f\u67e5\u770b\u5b98\u65b9\u7684\u8bf4\u660e\u6587\u6863\u5c31\u591f\u4e86\uff0c\u6240\u4ee5\u5177\u4f53\u7684\u4e00\u4e9b\u8bbe\u7f6e\u6211\u5c31\u4e0d\u91cd\u590d\u4e86\u3002<br \/>\n\u6587\u6863\u94fe\u63a5\uff1a<a href=\"https:\/\/gohugo.io\/overview\/introduction\/\">\u5b98\u65b9\u6587\u6863<\/a>\uff0c<a href=\"https:\/\/github.com\/spf13\/hugoThemes\">\u76ae\u80a4<\/a>\uff0c<a href=\"https:\/\/gohugo.io\/overview\/configuration\/\">Configuring Hugo<\/a>\uff0c<a href=\"https:\/\/gohugo.io\/content\/front-matter\/\">Front Matter<\/a>\uff0c<a href=\"https:\/\/gohugo.io\/extras\/menus\/\">Menus<\/a>\uff0c<a href=\"https:\/\/gohugo.io\/templates\/variables\/\">Template Variables<\/a>\uff0c<a href=\"https:\/\/gohugo.io\/tutorials\/github-pages-blog\/\">Hosting on GitHub Pages<\/a>\uff0c<a href=\"http:\/\/www.gohugo.org\/\">\u4e2d\u6587\u6587\u6863<\/a>\u3002<\/p>\n<h2>\u5173\u4e8e\u90e8\u7f72<\/h2>\n<p>\u5047\u8bbe\u4f60\u9700\u8981\u90e8\u7f72\u5728 GitHub Pages \u4e0a\uff0c\u9996\u5148\u5728GitHub\u4e0a\u521b\u5efa\u4e00\u4e2aRepository\uff0c\u547d\u540d\u4e3a\uff1acoderzh.github.io \uff08coderzh\u66ff\u6362\u4e3a\u4f60\u7684github\u7528\u6237\u540d\uff09\u3002\u5728\u7ad9\u70b9\u6839\u76ee\u5f55\u6267\u884c Hugo \u547d\u4ee4\u751f\u6210\u6700\u7ec8\u9875\u9762\uff1a<\/p>\n<pre class=\"prettyprint linenums\" >\r\n$ hugo --theme=hyde --baseUrl=&quot;http:\/\/coderzh.github.io\/&quot;\r\n<\/pre>\n<p>\u5982\u679c\u4e00\u5207\u987a\u5229\uff0c\u6240\u6709\u9759\u6001\u9875\u9762\u90fd\u4f1a\u751f\u6210\u5230 public \u76ee\u5f55\uff0c\u5c06pubilc\u76ee\u5f55\u91cc\u6240\u6709\u6587\u4ef6 push \u5230\u521a\u521b\u5efa\u7684Repository\u7684 master \u5206\u652f\u3002<\/p>\n<pre class=\"prettyprint linenums\" >\r\n$ cd public\r\n$ git init\r\n$ git remote add origin https:\/\/github.com\/coderzh\/coderzh.github.io.git\r\n$ git add -A\r\n$ git commit -m &quot;first commit&quot;\r\n$ git push -u origin master\r\n<\/pre>\n<p>\u6d4f\u89c8\u5668\u91cc\u8bbf\u95ee\uff1ahttp:\/\/coderzh.github.io\/<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u8be5\u6587\u6574\u7406\u81ea\u7f51\u7edc\uff0c\u66f4\u591a\u8be6\u7ec6\u5185\u5bb9\u89c1\u8fd9\u91cc\u3002 Hugo\u662f\u4e00\u4e2a\u7528Go\u8bed\u8a00\u7f16\u5199\u7684\u9759\u6001\u7f51\u7ad9\u751f\u6210\u5668\uff0c\u5b83\u4f7f\u7528\u8d77\u6765\u975e\u5e38\u7b80\u5355\uff0c\u76f8\u5bf9\u4e8e [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[12],"tags":[32],"_links":{"self":[{"href":"http:\/\/www.thinkmesh.net\/index.php?rest_route=\/wp\/v2\/posts\/336"}],"collection":[{"href":"http:\/\/www.thinkmesh.net\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.thinkmesh.net\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.thinkmesh.net\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/www.thinkmesh.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=336"}],"version-history":[{"count":22,"href":"http:\/\/www.thinkmesh.net\/index.php?rest_route=\/wp\/v2\/posts\/336\/revisions"}],"predecessor-version":[{"id":358,"href":"http:\/\/www.thinkmesh.net\/index.php?rest_route=\/wp\/v2\/posts\/336\/revisions\/358"}],"wp:attachment":[{"href":"http:\/\/www.thinkmesh.net\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=336"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.thinkmesh.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=336"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.thinkmesh.net\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=336"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}