https://github.com/cljoly/gohugo-shorturl
๐ Hugo module to create shorturls (so your shorturl like my.site/short can redirect to asitewithalong.name/andanevenlongerpath)
https://github.com/cljoly/gohugo-shorturl
gohugo gohugoio hacktoberfest hugo hugo-module static-site static-site-generator
Last synced: about 2 months ago
JSON representation
๐ Hugo module to create shorturls (so your shorturl like my.site/short can redirect to asitewithalong.name/andanevenlongerpath)
- Host: GitHub
- URL: https://github.com/cljoly/gohugo-shorturl
- Owner: cljoly
- License: apache-2.0
- Created: 2019-09-16T21:33:56.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2023-04-30T13:25:05.000Z (about 2 years ago)
- Last Synced: 2025-02-25T22:11:16.271Z (2 months ago)
- Topics: gohugo, gohugoio, hacktoberfest, hugo, hugo-module, static-site, static-site-generator
- Language: HTML
- Homepage: https://joly.pw/gohugo-shorturl
- Size: 16.6 KB
- Stars: 8
- Watchers: 2
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# GoHugo Shorturl

Create shorter urls to external resources for your own convenience or to your own content, to get the [benefits described by Derek Sivers](https://sive.rs/su).
## Install
If you havenโt used hugo modules before (you need the go compiler):
```
hugo mod init
```
more details in [hugo docs](https://gohugo.io/hugo-modules/use-modules/).Then run:
```
hugo mod get -u -v joly.pw/gohugo-shorturl
```
and edit your hugo config, for instance for `config.toml```` toml
[module]
[[module.imports]]
path = "joly.pw/gohugo-shorturl"
```## Use
Imagine we want to create the short url *https://my.site/a* and to have it redirect to *https://gohugo.io/content-management/archetypes/#directory-based-archetypes*:
```
hugo new --kind shorturl content/a.md
```
and then edit `content/a.md`:
``` yaml
---
title: "A"
date: 2021-03-07T13:57:13Z
draft: true
type: "shorturl"
shortto: ""
---
```
Change the `shortto` above to *https://gohugo.io/content-management/archetypes/#directory-based-archetypes* and `draft` to `false`
``` yaml
---
title: "A"
date: 2021-03-07T13:57:13Z
draft: true
type: "shorturl"
shortto: "https://gohugo.io/content-management/archetypes/#directory-based-archetypes"
---
```Then deploy *my.site* and open *https://my.site/a*, you will be redirected!
## Other parameters
See https://developers.google.com/search/docs/advanced/robots/robots_meta_tag?hl=en#directives
## Contribute
You may use a local version of this module in hugo like this:
```toml
[module]
replacements = "joly.pw/gohugo-shorturl -> /some/path/gohugo-shorturl"
[[module.imports]]
path = "joly.pw/gohugo-shorturl"
```Please consider sending a PR with your patches, itโs always appreciated and will save you the trouble of maintaining the changes on your own!