惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

酷 壳 – CoolShell
酷 壳 – CoolShell
H
Hacker News: Front Page
P
Palo Alto Networks Blog
T
ThreatConnect
Apple Machine Learning Research
Apple Machine Learning Research
博客园_首页
T
True Tiger Recordings
P
Privacy & Cybersecurity Law Blog
B
Blog
IT之家
IT之家
Last Week in AI
Last Week in AI
F
Full Disclosure
Hacker News: Ask HN
Hacker News: Ask HN
C
Comments on: Blog
Microsoft Azure Blog
Microsoft Azure Blog
C
Cybersecurity and Infrastructure Security Agency CISA
Microsoft Security Blog
Microsoft Security Blog
博客园 - 【当耐特】
N
News and Events Feed by Topic
NISL@THU
NISL@THU
腾讯CDC
雷峰网
雷峰网
Security Latest
Security Latest
李成银的技术随笔
M
Microsoft Research Blog - Microsoft Research
L
LangChain Blog
L
Lohrmann on Cybersecurity
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
C
Check Point Blog
Y
Y Combinator Blog
Recent Announcements
Recent Announcements
博客园 - Franky
N
News | PayPal Newsroom
V
V2EX
A
About on SuperTechFans
The Register - Security
The Register - Security
月光博客
月光博客
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
Google Online Security Blog
Google Online Security Blog
MyScale Blog
MyScale Blog
Cisco Talos Blog
Cisco Talos Blog
Vercel News
Vercel News
WordPress大学
WordPress大学
C
Cyber Attacks, Cyber Crime and Cyber Security
The Hacker News
The Hacker News
IntelliJ IDEA : IntelliJ IDEA – the Leading IDE for Professional Development in Java and Kotlin | The JetBrains Blog
IntelliJ IDEA : IntelliJ IDEA – the Leading IDE for Professional Development in Java and Kotlin | The JetBrains Blog
爱范儿
爱范儿
A
Arctic Wolf
L
LINUX DO - 最新话题
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More

豆逗子的小黑屋

GEMINI-CLI settings 参数详情 使用 sing-box Tun 模式实现 V2rayU 的透明代理 浅析 Claude Code 的执行与提示词 多模态模型是如何处理和理解图片的? 从配料表出发:便秘的猫应该怎么选主食 盘点开源的 DeepResearch 实现方案 浅谈 DeepSeek-R1 和 Kimi k1.5 论文中的思维链 + 强化学习 使用 TiDB Vector 构建 LightRAG 知识库 从论文到源码:详解 RAG 算法 云南之行——游在大理食在昆明 浅入浅出 Rerank 模型 一年同行:我的TiDB社区之旅 读书笔记《大语言模型》 TiDB Vector + Dify 快速构建 AI Agent 基于 LLM 推动游戏叙事 HTTP/2 和 CONTINUATION Flood 混合专家模型 (MoE) 笔记 报告分享: IMF第四次磋商报告 和 美联储研究笔记 使用 Coze 搭建 TiDB 助手 2023年总结 读书笔记《大规模语言模型:从理论到实践》 TiDB知识点梳理 (PCTA 笔记) 向量相似性检索方法 Java & Go 线程模式对比 Hugo + umami 博客统计面板 资产配置 101 探究 Spring-Boot 内置Server 搭建Go版本Kubernetes微服务示例 为什么Spring可以“自己注入自己” Go语言指针性能 从固定走向浮动 ——《时运变迁》读书笔记 Netty 源码分析及内存溢出思路 推荐 笔记 看得见的手——《置身事内》读书笔记 2022年初读书回顾 荐书:《走出唯一真理观》 nintendo switch 关于 邮箱
博客搭建简述
2022-12-09 · via 豆逗子的小黑屋

Hugo 及其镜像 #

  具体文件详见 HUGO安装文档,下面主要解释一下docker部署的方式。

docker镜像地址:https://hub.docker.com/r/klakegg/hugo
github地址:https://github.com/klakegg/docker-hugo

  lakegg/hugo镜像有基于BusyboxAlpineDebianUbuntu4个系统.其中每个系统又分为normal、ext、onbuild、ci、ext-ci、ext-onbuild 6种,Busybox没有ext相关,下面简要介绍一下几种的区别

  • normal:只有基础的hugo命令。默认Entrypoint是hugo,所以common只需要写server,即可执行hogu server
  • ext:拓展版,在normal基础上添加了go、git、nodejs等拓展工具 (推荐)
  • ci: 主要用于持续集成/部署。在normal基础上,新增了环境变量HUGO_ENV,去掉了默认Entrypoint,需要自行添加容器运行命令
  • onbuild: 此版本主要用于编译构建并可以分开源码和产出。默认源码文件夹是/src,产出文件夹是.target,可以通过HUGO_DIR和HUGO_DESTINATION_ARG进行自定义设置。

docker镜像版本如下:

busybox Alpine Alpine with Asciidoctor Alpine with Pandoc Debian Ubuntu
normal latest
busybox
alpine asciidoctor pandoc debian ubuntu
ext - ext-alpine ext-asciidoctor ext-pandoc ext-debian ext-ubuntu
ci ci
busybox-ci
alpine-ci asciidoctor-ci pandoc-ci debian-ci ubuntu-ci
onbuild onbuild
busybox-onbuild
alpine-onbuild asciidoctor-onbuild ext-pandoc-onbuild debian-onbuild ubuntu-onbuild
ext-ci - ext-alpine-ci ext-asciidoctor-ci ext-pandoc-ci ext-debian-ci ext-ubuntu-ci
ext-onbuild - ext-alpine-onbuild ext-asciidoctor-onbuild ext-pandoc-onbuild ext-debian-onbuild ext-ubuntu-onbuild

hugo模板可以参考 https://themes.gohugo.io/

Blowfish模板使用 #

  Hugo的主题主要是用了blowfish,下面主要对blowfish的使用展开简要说明

  blowfish的github主要介绍了使用git submodules和Hugo的部署方式,这里主要介绍一下如何使用上面介绍的hugo docker镜像进行部署

  1. go.mod中添加blowfish
require github.com/nunocoracao/blowfish/v2 version // indirect
  1. config/_default/module.toml文件添加:
[[imports]]
path = "github.com/nunocoracao/blowfish/v2"
  1. 将根目录引用到镜像内的/src目录下,启动docker即可

  使用blowfish搭建博客,具体参考文档

自定义浏览器角标 #

  在favicon.io讲自己的图片生成为各种尺寸的icon,直接解压在favicon.io下载好的icon压缩包,并放在/static目录下即可

自定义ICON #

  将自定义的svg文件放在/asserts/icons目录下,为了使ICON和主题自适应,需要在svg文件中添加属性 fill=“currentColor” 如下:

<svg>
    <path fill="currentColor" d="xxx"/>
</svg>

中文字符数问题 #

  需要在 config/_default/config.toml 中添加属性,如下:

hasCJKLanguage = true

评论插件 #

  Hugo中的评论组件/服务可以参考 Comments。这里给出了十几种开源方案,大部分方案需要Docker或者Kubernetes部署。 此外有两种需要依赖 Github Discussions 或者 Github issues 的评论组件——giscusutterances。下面以giscus为例。

  在 blowfish 主题中添加 comment 可以参考 blowfish-Comments

  简单描述一下,添加文件 layouts/partials/comments.html,具体的内容参考giscus 中的示例:

<script src="https://giscus.app/client.js"
        data-repo="[在此输入仓库]"
        data-repo-id="[在此输入仓库 ID]"
        data-category="[在此输入分类名]"
        data-category-id="[在此输入分类 ID]"
        data-mapping="pathname"
        data-strict="0"
        data-reactions-enabled="1"
        data-emit-metadata="0"
        data-input-position="bottom"
        data-theme="preferred_color_scheme"
        data-lang="zh-CN"
        crossorigin="anonymous"
        async>
</script>

GitHub Page 部署 Hugo #

  在 .github/workflows 目录下添加yml,文档参考Host on GitHub Pages,具体的yml内容示例如下:

name: Deploy Hugo site to Pages

on:
  push:
    branches: ["main"]
  workflow_dispatch:

permissions:
  contents: read
  pages: write
  id-token: write

concurrency:
  group: "pages"
  cancel-in-progress: false

# Default to bash
defaults:
  run:
    shell: bash

jobs:
  # 构建
  build:
    runs-on: ubuntu-latest
    env:
      # Hugo 版本
      HUGO_VERSION: 0.121.0
    steps:
      - name: Install Hugo CLI
        run: |
          wget -O ${{ runner.temp }}/hugo.deb https://github.com/gohugoio/hugo/releases/download/v${HUGO_VERSION}/hugo_extended_${HUGO_VERSION}_linux-amd64.deb \
          && sudo dpkg -i ${{ runner.temp }}/hugo.deb
      - name: Install Dart Sass
        run: sudo snap install dart-sass
      - name: Checkout
        uses: actions/checkout@v3
        with:
          submodules: recursive
      - name: Setup Pages
        id: pages
        uses: actions/configure-pages@v3
      - name: Install Node.js dependencies
        run: "[[ -f package-lock.json || -f npm-shrinkwrap.json ]] && npm ci || true"
      - name: Build with Hugo
        env:
          HUGO_ENVIRONMENT: production
          HUGO_ENV: production
        run: |
          hugo \
            --minify \
            # 博客地址
            --baseURL "https://example.com"
      - name: Upload artifact
        uses: actions/upload-pages-artifact@v2
        with:
          # hugo 构建后默认生成到 public 目录下
          path: ./public

  # 部署
  deploy:
    environment:
      name: github-pages
      # 博客地址
      url: https://example.com
    runs-on: ubuntu-latest
    needs: build
    steps:
      - name: Deploy to GitHub Pages
        id: deployment
        uses: actions/deploy-pages@v2

集成 Umami 的站点统计 #

这部分写到另一个文章中了,具体可以看这个

Hugo + umami 博客统计面板