gohugo shorturl
1.0.0
為了您自己的方便或您自己的內容建立較短的外部資源 URL,以獲得 Derek Sivers 描述的好處。
如果你之前沒有使用過hugo模組(你需要go編譯器):
hugo mod init <my-module-path>
Hugo 文件中有更多詳細資訊。
然後運行:
hugo mod get -u -v joly.pw/gohugo-shorturl
並編輯你的hugo配置,例如config.toml
[ module ]
[[ module . imports ]]
path = " joly.pw/gohugo-shorturl "
想像一下,我們想要建立短網址https://my.site/a並將其重新導向到https://gohugo.io/content-management/archetypes/#directory-based-archetypes :
hugo new --kind shorturl content/a.md
然後編輯content/a.md
:
---
title : " A "
date : 2021-03-07T13:57:13Z
draft : true
type : " shorturl "
shortto : " "
---
將上面的shortto
更改為https://gohugo.io/content-management/archetypes/#directory-based-archetypes並將draft
為false
---
title : " A "
date : 2021-03-07T13:57:13Z
draft : true
type : " shorturl "
shortto : " https://gohugo.io/content-management/archetypes/#directory-based-archetypes "
---
然後部署my.site並開啟https://my.site/a ,您將被重定向!
請參閱 https://developers.google.com/search/docs/advanced/robots/robots_meta_tag?hl=en#directives
您可以在 Hugo 中使用此模組的本機版本,如下所示:
[ module ]
replacements = " joly.pw/gohugo-shorturl -> /some/path/gohugo-shorturl "
[[ module . imports ]]
path = " joly.pw/gohugo-shorturl "
請考慮發送帶有您的補丁的 PR,我們總是會感激您,並且會為您省去自行維護更改的麻煩!