【Hugo入门】基础用法

检查Hugo是否安装

hugo version

显示所有可用命令

hugo help

显示指定命令的可用子命令,例如查询server的所有子命令

hugo server --help

建立你的网站,cd进入你的项目根目录运行

hugo

默认发布内容到自动创建的public文件夹


覆盖hugohugo server的默认行为

hugo -D # or -buildDrafts
hugo -E # or -buildExpired
hugo -F # or -buildFuture

你也可以在网站配置文件中设置它们。


在你编辑内容或布局时实时观察你的网站变化

hugo server

hugo server编译你的网站后放进内存中,并提供简易的HTTP服务,你能够在http://localhost:1313/访问到你的网站。

它会监听assets、配置文件、contentdatalayouts、翻译文件和static的变化。

其工作机制是LiveReload


自动重定向到你正在编辑的页面

hugo server --navigateToChanged

部署你的网站

Hugo不会自动删除hugo命令生成的public目录,需要我们手动删除。

public目录结构类似于下面:

public/
├── categories/
│   ├── index.html
│   └── index.xml  <-- 网站的RSS源
├── post/
│   ├── my-first-post/
│   │   └── index.html
│   ├── index.html
│   └── index.xml  <-- 网站的RSS源
├── tags/
│   ├── index.html
│   └── index.xml  <-- 网站的RSS源
├── index.html
├── index.xml      <-- 网站的RSS源
└── sitemap.xml

通常通过CI/CD工作流,将网站的内容部署到Github等服务器。

了解CI/CD工作流

猜你喜欢

转载自blog.csdn.net/2201_75288929/article/details/132483763