Configure noUgly support for custom output type?

Hi folks, I’m working through getting my Hugo installation to output gemini protocol compatible pages. I’m not the first, but things have moved on a bunch in the Hugo world in the past few years, and lots seems easier!

One thing I’m struggling with is that {{ .RelPermalink }} links to pages always include the “ugly” suffix rather than omitting it (eg. /posts/kebab-title/index.gmi is produced, instead of /posts/kebab-title/.)

My gemini server (agate) supports delivering index.gmi if a directory is requested, like many HTTP servers — I’d like to take advantage of this! The HTML site that’s built alongside the gemini one works as expected ({{ .RelPermalink }} references point to /posts/kebab-title/ not /posts/kebab-title/index.html), so I’m not sure what I’m missing.

I think I’ve configured the output type correctly, but I have a hunch I’m missing a config option somewhere, and I can’t find the reference in the docs anywhere. I’ve configured the output format like this:

    name = 'Gemini'
    isPlainText = true
    isHTML = false
    mediaType = 'text/gemini'
    protocol = 'gemini://'
    permalinkable = true
    noUgly = true

Does anyone have a hint as to what I’m missing?

looks like there’s (still?) a bug(?) with just one output type.

maybe this can help

especially the comment from @jmooring


To clarify, this is not related to the uglyURLs setting in root of the site configuration, nor it is related to the ugly or noUgly setting for a given output format.

This site configuration…

suffixes = ['gmi']

isPlainText = true
mediaType = 'text/gemini'
permalinkable = true
protocol = 'gemini://'

page = ['html','gemini']
section = ['html','gemini']

…renders a list page such as public/posts/index.gmi like this:

Title: Post 2
Permalink: gemini://

The above is a pretty URL, in that it can be served from either of these locations if the production server is properly configured:

  • gemini://
  • gemini://

The only way to render the first form is something like this in layouts/_default/list.gemini.gmi:

{{ range .Pages }}
  Title: {{ .Title }}
  Permalink: {{ print (.Permalink | path.Dir) "/" }}
{{ end }}

You may have to do something similar in your render hooks if are rendering .Content instead of .RawContent or .RenderShortcodes.

1 Like

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.