Add abbrlink to Hugo

I am a former user of hexo and recently migrated my blog to hugo. There is a plugin for hexo called hexo-abbrlink that can generate short URLs based on file names or titles, such as Is it possible for hugo to support generating short URLs with an abbrlink param?

Do you want to change the URL from which the page is served, or do you want to provide an alternate URL?

To change the URL.

You will have to set the URL of each page when creating the page with hugo new. Add this to your archetype template (archetypes/

url ='{{ now.UnixNano | crypto.FNV32a }}'

This will set the URL to something like:

Or you could use crypto.SHA256 and use the first seven or eight characters, etc.

By using the time created, we can change the title or path and the permalink will not change.

Thank you very much for your advice, it is very helpful. I’m writing code to define a slug in front matter, maybe like this

slug: {{ .Abbrlink }}
abbrlink: {{ .Abbrlink }}

I’m using hex crc32 value based on TITLE.

I assume it is not possible to set

  url: '{{ .Title | crypto.FNV32a }}'

somewhere instead ?

No, it is not. With the exception of archetypes, you cannot place template code in front matter.

Can I create a PR adding a new field in archetypeFileData?
It’s a new feature, supports to generate short permalink with crc32 algorithm.

I think that is unlikely to be accepted. If I want a hash in my front matter, then I should be able to specify the input (path, title, date, now, etc.).

If you want a template function, I suggest you create a proposal to implement, probably in the crypto namespace, with signature:



  • defaults to the predefined Castagnoli constant (yields crc32c)
  • accepts any of the predefined constants (IEEE, Castagnoli, or Koopman)
  • accepts any valid arbitrary value

And you better have a compelling justification, explaining why these are not acceptable:


1 Like