• hugo搭建个人博客


    注意

    本次搭建环境在Linux下进行
    Demo: https://blog.fredliang.cn/

    参考文档

    Hugo中文文档 https://www.gohugo.org/
    主题文档 https://github.com/nanxiaobei/hugo-paper

    Go 语言环境安装(linux)

    1、下载二进制包:go1.4.linux-amd64.tar.gz。

    https://golang.google.cn/dl/
    

    2、将下载的二进制包解压至 /usr/local目录。

    tar xvf go1.15.5.linux-amd64.tar.gz -C /usr/local
    

    3、将 /usr/local/go 目录添加至PATH环境变量:
    vim /etc/profile 最后一行添加以下内容

    export GOROOT=/usr/local/go
    export PATH=$PATH:$GOROOT/bin
    

    4、生效

    source /etc/profile
    

    5、测试
    输入go version
    如果正常会输出以下信息

    go version go1.15.5 linux/amd64
    

    部署hugo

    1、打开GitHub下载hugo Releases

    https://github.com/gohugoio/hugo/releases
    

    2、找到hugo_0.79.0_Linux-64bit.tar.gz
    下载并打开,将压缩包中的hugo上传到服务器/usr/bin目录下
    3、授权执权限,否则无法启动

    -bash: /usr/bin/hugo: 权限不够
    

    执行以下命令完成授权

    chmod +x /usr/bin/hugo
    

    4、检查是否正常输出
    执行hugo version命令
    查看正常输出

    [root@qwq ~]# hugo version
    Hugo Static Site Generator v0.79.0-1415EFDC linux/amd64 BuildDate: 2020-11-27T09:09:02Z
    

    生成站点

    1、使用Hugo快速生成站点,生成到 /site 路径:

    hugo new site /site
    

    会输出以下内容

    [root@qwq ~]# hugo new site /site
    Congratulations! Your new Hugo site is created in /site.
    
    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.
    

    这样就在 /site 目录里生成了初始站点,进去目录:

    cd /site
    

    站点目录结构:

      ▸ archetypes/
      ▸ content/
      ▸ layouts/
      ▸ static/
        config.toml
    

    2、创建一篇测试页面
    创建一个 test 页面:

    [root@qwq site]# hugo new test.md
    /site/content/test.md created
    

    test.md 自动生成到了 site/content/test.md ,使用cat命令打开 test.md 看下:

    [root@qwq site]# cat content/test.md 
    ---
    title: "Test"
    date: 2020-11-29T23:40:05+08:00
    draft: true
    ---
    

    3、创建第一篇文章,放到 post 目录,方便之后生成聚合页面。

    [root@qwq site]# hugo new post/first.md
    /site/content/post/first.md created
    

    4、打开编辑 post/first.md

    echo "#这是一简单的页面" >> content/post/first.md
    

    安装refine主题

    进入到你的hugo目录/site 执行下面的命令

    git submodule add https://github.com/nanxiaobei/hugo-paper themes/paper
    

    如果网络太慢可以手动进入GitHub下载。然后上传到themes目录下也可以
    将主题包中的theme.toml复制到/site目录下并替换

    cd /site/themes/paper/
    [root@qwq paper]# cp theme.toml /site/config.toml 
    cp:是否覆盖"/site/config.toml"? y
    

    config.toml更改为你的内容

    /site/config.toml
    

    在你的站点根目录执行 Hugo 命令进行调试:

  • 相关阅读:
    HDU 1221 Rectangle and Circle 考虑很多情况,good题
    HDU 1223 打表 + 大数
    17984 FFF团的怒火
    17978 倒不了的塔 注意题目
    .. HDU
    17972 Golden gun的巧克力
    9718 整数因子分解(必做) 分治法
    51NOD 1201 整数划分
    Amazon Rekognition 人脸识别
    AWS Config
  • 原文地址:https://www.cnblogs.com/iXiAo9/p/14058947.html
Copyright © 2020-2023  润新知