Deng’s self-built blog Thunderhit is now open

Python data mining and text analysis & Stata application ability improvement and empirical frontiers have begun to sign up~

I saw a video of a blogger using Hugo to make a personal blog at station B. It feels very simple. You can see his blog appear in the cloud within ten minutes. Of course, I want to make my blog more beautiful and cool. It takes a lot of effort to craft it. Now everyone can see the effect, Da Deng spent a whole day, a little modification and change.

Deng’s self-built blog Thunderhit is now open

table of Contents

  1. Install Hugo
  2. New Hugo project
  3. Academic theme download
  4. Start a local blog
  5. Create a new article locally
  6. Deploy the local blog to the server
    More
    experimental code downloads

1. Install Hugo
Here take Mac as an example, install Hugo, enter the command line


brew install hugo

2. Create a new Hugo project and
switch to the desktop (I like to put the project on the desktop), execute from the command line


cd desktop

Create a new hugo project folder called MyBlog and execute it on the command line

hugo new site MyBlog

Now you can see a MyBlog folder on the desktop, then switch the working directory to MyBlog


cd MyBlog

Reporter currently our command line is in the root directory of MyBlog, next download the website theme

3. Academic theme download
Hugo has many themes, I chose https://themes.gohugo.io/academic/ ,

Execute the following commands line by line on the command line


cd themes

git clone https://github.com/gcushen/hugo-academic.git

{{% alert note %}} We can see an additional hugo-academic folder in MyBlog/themes, change hugo-academic to academic, and now the website has been established~{{% /alert %}}

{{% alert warning %}} Here switch back to the project root directory MyBlog{{% /alert %}}


cd ..

Execute pwd from the command line, check the directory


pwd

get


/Users/电脑用户名/desktop/MyBlog

4. Start a local blog.
Now we take the academic theme as an example to start a blog

Command line execution


hugo server -t academic --buildDrafts

{{% alert note %}}Supplement: t means subject {{% / alert %}}

After execution, we will be prompted in the command line


http://localhost:1313/

Copy and paste the link above in the browser, and our Blog rough house is built~

5. Create a new article locally, which
is still the root directory of MyBlog, executed by the command line


hugo new post/first-article.md

{{% alert note %}} A new post folder is created in MyBlog/content, and there is a first-article.md file in the post. {{% /alert %}}

The next step is to use markdown to write content in first-article.md.

Let's test the current website, continue to return to the MyBlog root directory, execute the command line

hugo server -t academic --buildDrafts
In the browser, we can see the first Ariticle article.

**

  1. Deploy the local blog to the server**
    Create a new warehouse on github, the warehouse name method

<your github username>.github.io


比如我的github账号名是thunderhit,那么仓库名为

thunderhit.github.io


在MyBlog根目录,命令行执行

hugo --theme=academic --baseUrl='https://thunderhit.github.io/' --buildDrafts


{{% alert note %}}补充: 主题academic, 网站地址 https://thunderhit.github.io/,你们根据自己需要改成自己的仓库名{{% /alert %}}

现在我们在MyBlog中多了一个public文件夹,其中有我们新建的文章内容。

**绑定public与github仓库**

命令行切换到public目录,初始化git

cd public
git init
git add.
git commit -m'My hugo blog is submitted for the first time'


**把public与远程github仓库关联**

依次执行(大家的github地址略微不同,需要改动一下)

git remote add origin [email protected]:thunderhit/thunderhit.github.io.git

git push -u origin master



命令行上传完毕后,在浏览器网址栏打开链接 https://thunderhit.github.io/

就可以看到我们自己的博客了~

![](https://s4.51cto.com/images/blog/202012/30/16353ea4015cc8575d5df46eedb88a26.png?x-oss-process=image/watermark,size_16,text_QDUxQ1RP5Y2a5a6i,color_FFFFFF,t_100,g_se,x_10,y_10,shadow_90,type_ZmFuZ3poZW5naGVpdGk=)

**更多**
如果大家想学仔细学Hugo,推荐大家看B站Up主:ianianying的视频

**实验代码下载**
如果实验没成功,大家可以下载我的博客项目。项目资源获取方式,【公众号:大邓和他的Python】后台回复关键词"Hugo"

Guess you like

Origin blog.51cto.com/15069487/2578526