问题描述
我试图弄清楚Hugo如何在运行hugo server
时(自动)从Github文件夹中提取最新文件。特别是,我喜欢通过GitHub从Primer CSS中提取css文件。最好的实现方法是什么,这样我就不必总是在我的Git上手动更新Primer CSS?
module:
imports:
- disable: false
path: github.com/primer/css
mounts:
- source: src/scss
target: assets/scss/primer
Error: module "github.com/primer/css" not found; either add it as a Hugo Module or store it in "/Users/user/code/my-theme/themes".: module does not exist
是否有简单的最佳实践,可以自动从https://github.com/primer/css/(/ src)中提取最新文件并将其加载到/assets
文件夹中?或者是使用npm节点模块的唯一方法,例如:https://github.com/lucperkins/hugo-primer
谢谢!
解决方法
我为此苦了很长时间。关键是通过运行hugo mod init {anything}
将您的站点初始化为“运行模块”。这将创建一个go.mod
文件。因此,如果您运行hugo mod init mywebsite
会生成看起来像这样的go.mod
:
module mywebsite
go 1.14
require github.com/primer/css v1.0.0 // indirect
之后,这些模块将为您工作。