hugo-book icon indicating copy to clipboard operation
hugo-book copied to clipboard

Using .LinkTitle in file tree menu

Open dcx opened this issue 2 years ago • 1 comments

Hello, I'm not sure about this, but I think I've found a slight misalignment with the Hugo spec. So Hugo's front matter documentation says:

linkTitle: used for creating links to content; if set, Hugo defaults to using the linktitle before the title. Hugo can also order lists of content by linktitle.

However, linkTitle currently seems to be ignored in this theme's file tree menu and other spots. I think having this would be nice; the title on the page itself can be very long, whereas a long title looks kind of crazy in the file tree menu.

I believe the fix is to:

  1. Create a new partial specifically for cases where a title is meant as a link, e.g.: docs/linktitle.html
  2. This partial would look exactly the same as docs/title.html except with an extra if case:
    {{ if .LinkTitle }}
      {{ $title = .LinkTitle }}
    {{ else if .Title }}
      {{ $title = .Title }}
    ...
    
  3. Go through each call to docs/title.html and repoint it to the new partial if the title is being used in a link.

Does this seem like a reasonable solution to you? If so, I'd be happy to submit a pull request (I am not very familiar with open source, so I thought it best to raise this issue before doing so). Thanks - this is a really great theme, by the way!

dcx avatar Aug 18 '22 14:08 dcx

Hi! Sounds ok, we can change ref to .LinkTitle. Shoulb be backward compatible as far as I can tell.

alex-shpak avatar Sep 06 '22 08:09 alex-shpak