使用Hugo和GitHub搭建博客

{"type":"doc","content":[{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"折騰了幾天博客的框架終於搭建起來了。研究了一番之後,最終還是選擇使用Hugo和GitHub來搭建博客。本文介紹瞭如何使用Hugo來搭建靜態博客網站,並將其部署在GitHub上。使用"},{"type":"codeinline","content":[{"type":"text","text":"https://.github.io"}]},{"type":"text","text":"或者自定義的域名訪問博客。"}]},{"type":"heading","attrs":{"align":null,"level":2},"content":[{"type":"text","text":"Hugo的安裝和使用"},{"type":"link","attrs":{"href":"#fn1","title":null},"content":[{"type":"text","text":"1"}]}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"heading","attrs":{"align":null,"level":3},"content":[{"type":"text","text":"Hugo的安裝"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"初步使用Hugo的話,只需要跟隨官網的文檔過一遍"},{"type":"link","attrs":{"href":"https://gohugo.io/getting-started/quick-start/","title":null},"content":[{"type":"text","text":"Quick Start"}]},{"type":"text","text":"就可以瞭解基本的安裝、使用方法了。這裏根據我自己的經歷也進行簡單的說明。"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"在Mac系統,通過包管理工具"},{"type":"link","attrs":{"href":"https://brew.sh/","title":null},"content":[{"type":"text","text":"Homebrew"}]},{"type":"text","text":"可以非常簡單的安裝Hugo。"}]},{"type":"codeblock","attrs":{"lang":"shell"},"content":[{"type":"text","text":"brew install hugo"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"等待安裝完成之後,可以使用"},{"type":"codeinline","content":[{"type":"text","text":"hugo version"}]},{"type":"text","text":"命令來驗證。"}]},{"type":"heading","attrs":{"align":null,"level":3},"content":[{"type":"text","text":"建立新站點"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"接下來從終端進入到你想要放置博客站點內容的目錄下面使用"}]},{"type":"codeblock","attrs":{"lang":"shell"},"content":[{"type":"text","text":"hugo new site myblog"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"來建立站點。該命令會在當前目錄下新建一個名爲"},{"type":"codeinline","content":[{"type":"text","text":"myblog"}]},{"type":"text","text":"的文件夾。你所有的站點文件都會在這個文件夾下面存放。"}]},{"type":"heading","attrs":{"align":null,"level":3},"content":[{"type":"text","text":"添加主題"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"與其他的站點工具不同,Hugo沒有默認的主題,需要先添加一個主題才能新建文章。Hugo的官網上有很多的"},{"type":"link","attrs":{"href":"https://themes.gohugo.io/","title":null},"content":[{"type":"text","text":"主題"}]},{"type":"text","text":"可選。選定一個喜歡的主題之後,需要將其下載到"},{"type":"codeinline","content":[{"type":"text","text":"myblog"}]},{"type":"text","text":"文件夾中。在主題說明的頁面中點擊\"download\"的按鈕,會進入到對應的GitHub頁面中。有很多種方式可以將主題文件下載,並放置到"},{"type":"codeinline","content":[{"type":"text","text":"myblog/themes/"}]},{"type":"text","text":"文件夾中("},{"type":"codeinline","content":[{"type":"text","text":""}]},{"type":"text","text":"是主題的名稱,可以在該主題的GitHub倉庫的頁面看到)。在這裏爲了使用git對站點進行管理,實現在不同的設備上方便的對站點進行維護,我們使用git的submodule功能。"}]},{"type":"codeblock","attrs":{"lang":"shell"},"content":[{"type":"text","text":"cd myblog\ngit init\ngit submodule add https://github.com/budparr/gohugo-theme-.git themes/"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"接下來,我們需要在配置文件中指明站點所使用的主題。打開"},{"type":"codeinline","content":[{"type":"text","text":"config.toml"}]},{"type":"text","text":"直接編輯或者使用"},{"type":"codeinline","content":[{"type":"text","text":"echo 'theme = \"\"' >> config.toml"}]},{"type":"text","text":"命令。配置文件中還有其他的可配置內容,這些我們暫時不去管他。"}]},{"type":"heading","attrs":{"align":null,"level":3},"content":[{"type":"text","text":"新建文章"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"新建文章可以使用如下的命令,或者直接在"},{"type":"codeinline","content":[{"type":"text","text":"content//."}]},{"type":"text","text":"裏面手動創建。"}]},{"type":"codeblock","attrs":{"lang":"shell"},"content":[{"type":"text","text":"hugo new posts/my-first-post.md"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"在這裏建議使用Hugo的"},{"type":"codeinline","content":[{"type":"text","text":"new"}]},{"type":"text","text":"命令創建,因爲根據主題不同,使用"},{"type":"codeinline","content":[{"type":"text","text":"new"}]},{"type":"text","text":"命令創建的文件會包含簡單的模版框架。例如:"}]},{"type":"codeblock","attrs":{"lang":null},"content":[{"type":"text","text":"---\ntitle: my-first-post\ndate: 2020-06-13T19:45:22+08:00\nlastmod: 2020-06-13T19:45:22+08:00\nauthor: Author\ncover: /post/xxx-cover.jpg\ncategories: [\"技術\"]\ntags: [\"Hugo\", \"GitHub\"]\ndraft: true\n---"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"具體的配置方式和參數的意義,還請查看對應的主題說明。"}]},{"type":"heading","attrs":{"align":null,"level":3},"content":[{"type":"text","text":"文章中添加圖片"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"Hugo的配置文件和文章中引用圖片都是從"},{"type":"codeinline","content":[{"type":"text","text":"static"}]},{"type":"text","text":"作爲根目錄的。也就是說上面例子中的"},{"type":"codeinline","content":[{"type":"text","text":"/post/xxx-cover.jpg"}]},{"type":"text","text":"實際是在"},{"type":"codeinline","content":[{"type":"text","text":"static"}]},{"type":"text","text":"文件夾中。"}]},{"type":"codeblock","attrs":{"lang":"shell"},"content":[{"type":"text","text":".\n└── static\n\t└── post\n\t\t└── xxx-cover.jpg"}]},{"type":"heading","attrs":{"align":null,"level":3},"content":[{"type":"text","text":"開啓Hugo本地服務"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"我們需要將Hugo本地服務跑起來,才能看到上面操作的成果,看到新的站點的樣子。"}]},{"type":"codeblock","attrs":{"lang":"shell"},"content":[{"type":"text","text":"hugo server -D\n\n | EN\n+------------------+----+\n Pages | 10\n Paginator pages | 0\n Non-page files | 0\n Static files | 3\n Processed images | 0\n Aliases | 1\n Sitemaps | 1\n Cleaned | 0\n\nTotal in 11 ms\nWatching for changes in /Users/workspace/myblog/{content,data,layouts,static,themes}\nWatching for config changes in /Users/workspace/myblog/config.toml\nEnvironment: \"development\"\nServing pages from memory\nRunning in Fast Render Mode. For full rebuilds on change: hugo server --disableFastRender\nWeb Server is available at http://localhost:1313/ (bind address 127.0.0.1)\nPress Ctrl+C to stop"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"打開"},{"type":"link","attrs":{"href":"http://localhost:1313/","title":null},"content":[{"type":"text","text":"http://localhost:1313/"}]},{"type":"text","text":",我們就可以看到剛纔新建的站點了。此時標記爲草稿的文章也會展示,但是在實際部署站點的時候需要將文章中的"},{"type":"codeinline","content":[{"type":"text","text":"draft: true"}]},{"type":"text","text":"配置改爲"},{"type":"codeinline","content":[{"type":"text","text":"false"}]},{"type":"text","text":"。在本地服務開啓的時候,對站點的改變(修改配置,修改、新增文章等)會直接展示出來。"}]},{"type":"heading","attrs":{"align":null,"level":3},"content":[{"type":"text","text":"配置文件的修改"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"打開配置"},{"type":"codeinline","content":[{"type":"text","text":"config.toml"}]},{"type":"text","text":"可以看到很多的參數可以配置,這裏只描述最基本的內容,不同的主題可能會支持不同的參數配置,具體請看對應主題的說明文檔。"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"codeinline","content":[{"type":"text","text":"baseURL"}]},{"type":"text","text":"是站點的域名。"},{"type":"codeinline","content":[{"type":"text","text":"title"}]},{"type":"text","text":"是站點的名稱。"},{"type":"codeinline","content":[{"type":"text","text":"theme"}]},{"type":"text","text":"是站點的主題。"}]},{"type":"heading","attrs":{"align":null,"level":3},"content":[{"type":"text","text":"谷歌分析的配置"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"很多主題都支持谷歌分析,啓用谷歌分析需要配置追蹤ID。追蹤ID在谷歌分析的"},{"type":"link","attrs":{"href":"https://analytics.google.com/analytics/web/","title":null},"content":[{"type":"text","text":"官網"}]},{"type":"text","text":"註冊即可獲得。"}]},{"type":"heading","attrs":{"align":null,"level":3},"content":[{"type":"text","text":"Disqus評論系統的配置"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"很多主題都支持評論系統,針對不同的評論系統/主題有不同的配置方式。這裏簡單說明下Disqus的配置。一般而言你只需要在支持Disqus的主題中配置Disqus的shortname即可。"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"shortname在"},{"type":"link","attrs":{"href":"https://disqus.com/profile/login/","title":null},"content":[{"type":"text","text":"Disqus"}]},{"type":"text","text":"的官網進行註冊便可以獲得。在註冊過程就可以看到你的站點的shortname,如果遺忘的話,"},{"type":"link","attrs":{"href":"https://disqus.com/admin/settings/general/","title":null},"content":[{"type":"text","text":"admin-setting"}]},{"type":"text","text":"頁面也可以找到。"}]},{"type":"heading","attrs":{"align":null,"level":2},"content":[{"type":"text","text":"在GitHub部署個人博客"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"因爲是個人博客,所以我們使用GitHub Pages的User Pages功能,具體的功能描述,可以查看"},{"type":"link","attrs":{"href":"https://help.github.com/en/github/working-with-github-pages","title":null},"content":[{"type":"text","text":"官方文檔"}]},{"type":"text","text":"。"}]},{"type":"heading","attrs":{"align":null,"level":3},"content":[{"type":"text","text":"創建GitHub項目"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"首先我們需要在GitHub上新建兩個倉庫分別用來保存站點源文件和發佈站點。其中用來存放站點源文件的倉庫可以根據自己喜好命名(例如"},{"type":"codeinline","content":[{"type":"text","text":""}]},{"type":"text","text":"),而用來發布站點的倉庫的名稱需要使用"},{"type":"codeinline","content":[{"type":"text","text":".github.io"}]},{"type":"text","text":"。"}]},{"type":"heading","attrs":{"align":null,"level":3},"content":[{"type":"text","text":"本地項目與GitHub倉庫同步"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"在"},{"type":"codeinline","content":[{"type":"text","text":"myblog"}]},{"type":"text","text":"文件夾中新建"},{"type":"codeinline","content":[{"type":"text","text":".gitignore"}]},{"type":"text","text":"文件,並在其中添加下面的內容:"}]},{"type":"codeblock","attrs":{"lang":null},"content":[{"type":"text","text":"### Hugo ###\n# Generated files by hugo\n# /public/\n/resources/_gen/\n# /themes/\n\n# Executable may be added to repository\nhugo.exe\nhugo.darwin\nhugo.linux\n\n# OSX\n.DS_Store"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"其中"},{"type":"codeinline","content":[{"type":"text","text":"public"}]},{"type":"text","text":"文件夾裏面的內容是Hugo生成的靜態網頁文件,需要上傳至"},{"type":"codeinline","content":[{"type":"text","text":".github.io"}]},{"type":"text","text":",因爲下面會使用"},{"type":"codeinline","content":[{"type":"text","text":"git submodule"}]},{"type":"text","text":"所以這裏不需要忽略。"},{"type":"codeinline","content":[{"type":"text","text":"themes"}]},{"type":"text","text":"文件夾也是一樣。"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"由於在上面“添加主題”一節已經在"},{"type":"codeinline","content":[{"type":"text","text":"myblog"}]},{"type":"text","text":"文件夾下初始化過git,同時將themes使用"},{"type":"codeinline","content":[{"type":"text","text":"git submodule"}]},{"type":"text","text":"的方式進行了添加。所以現在只需要用一樣的方法處理"},{"type":"codeinline","content":[{"type":"text","text":"public"}]},{"type":"text","text":"文件夾。不過首先我們需要刪除一下現有的"},{"type":"codeinline","content":[{"type":"text","text":"public"}]},{"type":"text","text":"文件夾。"}]},{"type":"codeblock","attrs":{"lang":"shell"},"content":[{"type":"text","text":"rm -rf public\ngit submodule add -b master https://github.com//.github.io.git public"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"接下來要做的事情是使用"},{"type":"codeinline","content":[{"type":"text","text":"hugo -t "}]},{"type":"text","text":"來重建靜態站點,然後進入到"},{"type":"codeinline","content":[{"type":"text","text":"public"}]},{"type":"text","text":"文件夾內"},{"type":"codeinline","content":[{"type":"text","text":"commit"}]},{"type":"text","text":"所有的修改並上傳。在這裏我們同樣使用官網上介紹的部署腳本的方式。首先新建"},{"type":"codeinline","content":[{"type":"text","text":"deploy.sh"}]},{"type":"text","text":"腳本。"}]},{"type":"codeblock","attrs":{"lang":"shell"},"content":[{"type":"text","text":"#!/bin/sh\n\n# If a command fails then the deploy stops\nset -e\n\n# Print out commands before executing them\nset -x\n\nprintf \"\\033[0;32mDeploying updates to GitHub...\\033[0m\\n\"\n\n# Build the project.\nhugo -t \n\n# Go To Public folder\ncd public\n\n# Add changes to git.\ngit add .\n\n# Commit changes.\nmsg=\"rebuilding site $(date)\"\nif [ -n \"$*\" ]; then\n\tmsg=\"$*\"\nfi\ngit commit -m \"$msg\"\n\n# Push source and build repos.\ngit push origin master\n\n# Back to the origin folder\n# cd ..\n\n# rm -rf public\n"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"接下來就可以使用"},{"type":"codeinline","content":[{"type":"text","text":"./deploy.sh \"Your optional commit message\""}]},{"type":"text","text":"提交靜態頁面到"},{"type":"codeinline","content":[{"type":"text","text":".github.io"}]},{"type":"text","text":"上。成功之後,就可以從瀏覽器訪問"},{"type":"codeinline","content":[{"type":"text","text":"https://.github.io"}]},{"type":"text","text":"來查看你的博客內容了。然後我們將博客的源文件也提交至"},{"type":"codeinline","content":[{"type":"text","text":""}]},{"type":"text","text":"。"}]},{"type":"codeblock","attrs":{"lang":"shell"},"content":[{"type":"text","text":"git submodule init\ngit add .\ngit commit -m \"註釋\"\ngit remote add origin \ngit push -u origin master"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"後續不需要刪除"},{"type":"codeinline","content":[{"type":"text","text":"public"}]},{"type":"text","text":"文件,每次修改了站點內容之後,直接再次使用腳本進行部署。然後使用常規的方式將資源文件提交併更新至"},{"type":"codeinline","content":[{"type":"text","text":"GitHub"}]},{"type":"text","text":"。"}]},{"type":"codeblock","attrs":{"lang":"shell"},"content":[{"type":"text","text":"./deploy.sh \"Your optional commit message\"\ngit add .\ngit commit -m \"註釋\"\ngit push"}]},{"type":"heading","attrs":{"align":null,"level":3},"content":[{"type":"text","text":"在新的環境繼續工作"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"一旦轉移到新的環境,在新的電腦上工作就可以把之前同步到"},{"type":"codeinline","content":[{"type":"text","text":"GitHub"}]},{"type":"text","text":"上的博客源文件同步下來繼續工作。當然在此之前需要在新的環境下安裝Hugo。"}]},{"type":"codeblock","attrs":{"lang":"shell"},"content":[{"type":"text","text":"brew install hugo"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"同之前新建站點一樣,首先在終端中進入想要放置博客站點內容的目錄下,使用"},{"type":"codeinline","content":[{"type":"text","text":"git clone"}]},{"type":"text","text":"命令拉取"},{"type":"codeinline","content":[{"type":"text","text":"GitHub"}]},{"type":"text","text":"上的倉庫。然後將"},{"type":"codeinline","content":[{"type":"text","text":"submodule"}]},{"type":"text","text":"初始化,並更新。"}]},{"type":"codeblock","attrs":{"lang":"shell"},"content":[{"type":"text","text":"git clone myblog && cd \ngit submodule init\ngit submodule update"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"這個時候在新的環境中,兩個子模塊的倉庫不在任何分支上,需要進入到對應的目錄,然後使用"},{"type":"codeinline","content":[{"type":"text","text":"git checkout master"}]},{"type":"text","text":"將分支切換到"},{"type":"codeinline","content":[{"type":"text","text":"master"}]},{"type":"text","text":"上面。"}]},{"type":"codeblock","attrs":{"lang":"shell"},"content":[{"type":"text","text":"cd public\ngit checkout master\ncd ../themes/\ngit checkout master"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"接下來就可以在新的環境繼續工作了。部署站點或者提交更新的資源文件和之前都一樣。需要注意的是,新的環境因爲是從"},{"type":"codeinline","content":[{"type":"text","text":"GitHub"}]},{"type":"text","text":"上直接同步下來的,在原來的環境中使用"},{"type":"codeinline","content":[{"type":"text","text":"hugo new"}]},{"type":"text","text":"命令創建的空文件夾不會同步。當需要的時候需要自行新建。Hugo新建站點的時候目錄結構如下:"}]},{"type":"codeblock","attrs":{"lang":"shell"},"content":[{"type":"text","text":".\n├── archetypes\n├── config.toml\n├── content\n├── data\n├── layouts\n├── static\n└── themes"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"這些目錄結構的具體用途可以查看"},{"type":"link","attrs":{"href":"https://gohugo.io/getting-started/directory-structure/","title":null},"content":[{"type":"text","text":"官方文檔"}]},{"type":"text","text":"。"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"不論是在哪個環境對站點進行了更新,包括不限於修改配置文件、新建文章、刪除文章等,都需要及時的將站點源文件提交和同步至"},{"type":"codeinline","content":[{"type":"text","text":"GitHub"}]},{"type":"text","text":"。這樣在其他環境纔可以拉取最新的源文件,並繼續工作。在使用了"},{"type":"codeinline","content":[{"type":"text","text":"git pull"}]},{"type":"text","text":"拉取了站點源文件後,不要忘記使用"},{"type":"codeinline","content":[{"type":"text","text":"git submodule update"}]},{"type":"text","text":"更新子模塊。"}]},{"type":"heading","attrs":{"align":null,"level":3},"content":[{"type":"codeinline","content":[{"type":"text","marks":[{"type":"strong"}],"text":"git submodule"}]},{"type":"text","text":"的簡單說明"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"本文采用的方法使用了"},{"type":"codeinline","content":[{"type":"text","text":"git submodule"}]},{"type":"text","text":",在這裏對使用到的幾個命令進行簡單的說明,需要更多信息的可以查看"},{"type":"link","attrs":{"href":"https://git-scm.com/book/zh/v2/Git-%E5%B7%A5%E5%85%B7-%E5%AD%90%E6%A8%A1%E5%9D%97","title":null},"content":[{"type":"text","text":"官方文檔"}]},{"type":"text","text":",或者網上搜索其他教程。子模塊可以讓用戶在一個倉庫中使用其他倉庫的內容,並保持獨立的提交。"}]},{"type":"codeblock","attrs":{"lang":"shell"},"content":[{"type":"text","text":"git submodule add -b master https://github.com//.github.io.git "}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"在現有的倉庫中添加一個子模塊。"}]},{"type":"codeblock","attrs":{"lang":"shell"},"content":[{"type":"text","text":"git submodule init\ngit submodule update"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"在當前倉庫裏面初始化和更新子模塊。也可以使用"},{"type":"codeinline","content":[{"type":"text","text":"git submodule update --init"}]},{"type":"text","text":"。或者使用"},{"type":"codeinline","content":[{"type":"text","text":"git clone myblog --recursive"}]},{"type":"text","text":"在新的環境克隆倉庫及所有子模塊。"}]},{"type":"codeblock","attrs":{"lang":"shell"},"content":[{"type":"text","text":"cd public\ngit checkout master\ncd ../themes/\ngit checkout master"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"將子模塊中的分支切換到"},{"type":"codeinline","content":[{"type":"text","text":"master"}]},{"type":"text","text":"。"}]},{"type":"heading","attrs":{"align":null,"level":2},"content":[{"type":"text","text":"給博客配置自己的域名"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"首先你需要有個域名,域名可以在騰訊雲、阿里雲、name等域名提供商購買。然後在域名的管理頁面配置一個"},{"type":"codeinline","content":[{"type":"text","text":"www"}]},{"type":"text","text":"子域名指向"},{"type":"codeinline","content":[{"type":"text","text":".github.io"}]},{"type":"text","text":"的"},{"type":"codeinline","content":[{"type":"text","text":"CNAME"}]},{"type":"text","text":"記錄。接下來需要前往"},{"type":"codeinline","content":[{"type":"text","text":"GitHub"}]},{"type":"text","text":"的"},{"type":"codeinline","content":[{"type":"text","text":".github.io"}]},{"type":"text","text":"倉庫的管理頁面配置自定義域名。在倉庫頁面點擊settings菜單,然後在Custom domain處填入你的域名,並勾選下面的Enforce HTTPS選框。"}]},{"type":"image","attrs":{"src":"https://static001.geekbang.org/infoq/11/11ed6d46df6644f1bb12a762d33becf9.jpeg","alt":null,"title":"","style":[{"key":"width","value":"100%"},{"key":"bordertype","value":"none"}],"href":"","fromPaste":false,"pastePass":false}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"image","attrs":{"src":"https://static001.geekbang.org/infoq/93/93b22a930816a1b86f5051562fbcb692.jpeg","alt":null,"title":"","style":[{"key":"width","value":"100%"},{"key":"bordertype","value":"none"}],"href":"","fromPaste":false,"pastePass":false}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"numberedlist","attrs":{"start":null,"normalizeStart":1},"content":[{"type":"listitem","content":[{"type":"paragraph","attrs":{"indent":0,"number":1,"align":null,"origin":null},"content":[{"type":"text","text":"本文是根據Mac系統的使用進行撰寫的,使用其他系統的如果有不同之處還請參考官方文檔。 "},{"type":"link","attrs":{"href":"#ffn1","title":null},"content":[{"type":"text","text":"↩︎"}]}]}]}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}}]}
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章