使用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}}]}
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章