美文网首页
用hugo搭建个人博客

用hugo搭建个人博客

作者: 李明燮 | 来源:发表于2020-07-15 23:16 被阅读0次

这几天研究了用hugo搭建个人博客。

简单的整理了一下。

1.安装hugo(windows 请查看官网介绍 https://gohugo.io/getting-started/installing/

$ brew install hugo

之后检查版本

$ hugo version
Hugo Static Site Generator v0.37.1 darwin/amd64 BuildDate:

2.创建hugo 项目

$ hugo new site my-blog
Congratulations! Your new Hugo site is created in /Users/limingxie/Projects/my-blog.

Just a few more steps and you're ready to go:

1. Download a theme into the same-named folder.
   Choose a theme from https://themes.gohugo.io/, or
   create your own with the "hugo new theme <THEMENAME>" command.
2. Perhaps you want to add some content. You can add single files
   with "hugo new <SECTIONNAME>/<FILENAME>.<FORMAT>".
3. Start the built-in live server via "hugo server".

Visit https://gohugo.io/ for quickstart guide and full documentation.

3.添加模板

$ cd my-blog
$ git init
$ git submodule add https://github.com/keichi/vienna.git themes/vienna

4.添加内容(content目录下执行。例:/Users/limingxie/Projects/my-blog/content)

$ hugo new xxx/my-first-blog.md

编辑:my-first-blog.md

5.运行调试

$ hugo server -D

                   | EN
+------------------+----+
  Pages            | 16
  Paginator pages  |  0
  Non-page files   |  0
  Static files     | 14
  Processed images |  0
  Aliases          |  1
  Sitemaps         |  1
  Cleaned          |  0

Total in 26 ms
Watching for changes in /Users/limingxie/Projects/my-blog/{content,data,layouts,static,themes}
Serving pages from memory
Running in Fast Render Mode. For full rebuilds on change: hugo server --disableFastRender
Web Server is available at //localhost:1313/ (bind address 127.0.0.1)
Press Ctrl+C to stop

访问http://localhost:1313/调试~

6.Theme的设定

打开config.toml

baseURL = "https://limingxie.github.io/" //这baseURL是部署后的访问地址。
languageCode = "en-us"
title = "My New Hugo Site"
theme = "vienna" // 你使用的theme 名称

查看vienna Theme说明的话还可以做很多设置。

7.部署到GitHub

  1. 首先在GitHub上创建一个Repository,命名为:limingxie.github.io (这要和你的baseURL一致。)
    2)在/Users/limingxie/Projects/my-blog目录下执行以下命令
$ hugo --theme=vienna --buildDrafts --baseUrl="https://limingxie.github.io/"

                   | EN
+------------------+----+
  Pages            | 16
  Paginator pages  |  0
  Non-page files   |  0
  Static files     | 14
  Processed images |  0
  Aliases          |  1
  Sitemaps         |  1
  Cleaned          |  0

Total in 28 ms

--buildDrafts 不加会生成无内容的网站
--baseUrl要和config.toml的地址一致。

顺利的话会创建public文件(里面的内容就是你要上传的静态网站的文件。)

$ cd public
$ git init
$ git remote add origin https://github.com/limingxie/limingxie.github.io.git
$ git add -A
$ git commit -m "first commit"
$ git push -u origin master

浏览器里访问:https://limingxie.github.io/ 就可以访问你的博客了


欢迎大家的意见和交流

email: li_mingxie@163.com

相关文章

  • 用hugo搭建个人博客

    这几天研究了用hugo搭建个人博客。 简单的整理了一下。 1.安装hugo(windows 请查看官网介绍 htt...

  • hugo搭建个人博客

    hugo搭建个人博客 1. hugo的安装 windows下hugo的安装 在hugo的官网下载 hugo 的二进...

  • hugo 搭建个人博客

    1. 安装hugo 2. Create a New Site 3. Add a Theme 4. Add Som...

  • Hugo搭建个人博客

    Hugo 主流静态博客框架 搭建个人博客肯定会用到"静态博客框架",比较主流的有Hexo与Hugo。 Hexo是一...

  • 个人博客搭建(hugo)

    一.搭建前提须知: window系统,注册git 账号,本地安装git 1:下载hugo (https:/git...

  • 如何用hugo 搭建博客

    1,Hugo 简介 搭建个人博客有很多开源的博客框架,我们要介绍的框架叫作Hugo。Hugo 是一个基于Go 语言...

  • 用Hugo快速搭建个人静态博客

    最近心血来潮,想要重新折腾一番自己的博客。于是,发现了Hugo比之前使用的Jekyll更好用。本文是个人参照Hug...

  • 用 Hugo 快速搭建博客

    用Hugo搭建博客 Hugo 是一个用Go编写的静态站点生成器,生成速度很快下面是具体操作: 1.安装 Hugo ...

  • 使用HUGO搭建个人博客

    本文首发于我的个人博客:Suixin's Blog Hugo是一个用Go编写的静态站点生成器,由于具有丰富的主题资...

  • 使用 Hugo 搭建个人博客

    一、从 Hugo 的 GitHub Releases 下载与操作系统相对应的二进制文件 由于我使用的是 Windo...

网友评论

      本文标题:用hugo搭建个人博客

      本文链接:https://www.haomeiwen.com/subject/qrpshktx.html