I see these two used a lot interchangeably in different themes/projects/tutorials. Is there a reason for this? Or a preference for one over the other?
Here are a couple of cases where an absolute URL (
.Permalink) is preferred:
- RSS feeds (Hugo’s internal template uses absolute URLs)
- Multilingual, multihost sites
- Language switcher
- Menu template (pass
- Shared resources
There may be others.
I have used
.Permalink in my theme before I encountered
.RelPermalink. Other than cases that require absolute paths, should I default to the latter? Or that is just a matter of choice?
I think it’s largely a matter of choice. Although this is just noise, you save a few bytes on each link.
The later saves 13 bytes.
But once it’s compressed while serving this is just noise.
Another advantage of .RelPermalink is the ability to use the produced pages offline from the file system (although it may requires additional settings or theme support).
Thanks. I went through my template and these are the areas I left
- RSS and Sitemap templates.
- Head/Foot partial files (canonical, open graph, JSON-LD).
- Post share buttons.
I have read through the
headless docs if that’s what you are referring to. I don’t have a use case for that yet.
This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.