写文章
快速写文章
输入hugo new 文章名称.md
就会在content目录下生成 “文章名称.md” 名字的文件,所有文章都是放在content这个文件夹里
如果自己还定义了分类目录,如在content目录的posts目录下有blog、read、tech、life等文章分类,那么在用命令生成文章的时候,如果要把文章生成到指定目录,可以用命令:hugo new posts/tech/文章名称.md
,这样就会把文章生成到tech目录下
生成的文章内部头部配置信息包括一些文章名称,时间之类的信息,可以事先在目录archetypes/default.md下使用模板,这样在用命令hugo new生成文章后会自动加上模板里的配置
文章基本模板
---
title: "Blog"
date: 2022-05-05T00:18:23+08:00
lastmod: 2022-05-05T00:18:23+08:00
author: ["AustinMa"]
keywords:
- 建站指南
categories:
- 建站指南
tags:
- blog
description: "这是一些基础的建站指南"
weight: 1
slug: ""
draft: false # 是否为草稿
comments: true
reward: true # 打赏
mermaid: true #是否开启mermaid
showToc: true # 显示目录
TocOpen: true # 自动展开目录
hidemeta: false # 是否隐藏文章的元信息,如发布日期、作者等
disableShare: true # 底部不显示分享栏
showbreadcrumbs: true #顶部显示路径
cover:
image: "" #图片路径例如:posts/tech/123/123.png
caption: "" #图片底部描述
alt: ""
---
文章插入图片
在文章里面使用本地图片的方式:
比如我在content/posts/tech/下有一篇文章叫做 fft.md,那么在和该文章同一目录下新建一个文件夹叫做fft,里面放图片如叫做 picture.png 的图片,那么在fft.md里面调用的时候可以这样写: ![](picture.png)
部署问题
写完文章更新Public
hugo --theme=hugo-PaperMod --baseUrl="https://mksasx.github.io/" --buildDrafts
或者
hugo -F --cleanDestinationDir
部署到github样式不显示
错误描述
在 Github Pages 上部署 Hugo 博客后,网站样式丢失,打开浏览器 F12 控制台可以发现错误:Failed to find a valid digest in the 'integrity' attribute for resource "xxx.css", The resource has been blocked.
错误解决
将\layouts\partials\head.html
以及themes\hugo-PaperMod\layouts\partials
里的integrity="{{ $stylesheet.Data.Integrity }}"
这么一句代码,把它改为 integrity=""
然后重新发布
有些使用者会部署到github,可能遇到跨系统的问题,如提示LF will be replaced by CRLF in ******
,这时输入命令:git config core.autocrlf false
,解决换行符自动转换的问题。
提示LF will be replaced by CRLF in ****
错误描述
git add时提示LF will be replaced by CRLF in ****
错误解决
输入命令:git config core.autocrlf false,解决换行符自动转换的问题。