Getting a filename without the extension

I’m trying to figure out how to use .File.BaseFileName (if that’s the correct way to do this anyway). I have the following code that pulls all of the page resource images into a photo gallery:

<ul class="uk-slideshow-items">
                {{ with .Resources.ByType "image" }}
                {{ range . }}
                <li>
                    <img sizes="
                    (min-width: 1200px) 730w,
                    (max-width: 1199px) 610w,
                    (max-width: 380px) 350w"
                         data-srcset="
                    {{ (.Resize "350x q100").Permalink }} 350w,
                    {{ (.Resize "610x q100").Permalink }} 610w,
                    {{ (.Resize "730x q100").Permalink }} 730w"
                    data-src="
                    {{ (.Resize "730x q100").Permalink }}" alt="{{ .Name }}" uk-cover uk-img="target: !.uk-slideshow-items">
                    <div class="uk-transition-slide-bottom uk-position-bottom uk-overlay uk-overlay-primary uk-text-center">
                        <p class="uk-h4 uk-margin-remove">{{ .File.BaseFileName }}</p>
                    </div>
                </li>
                {{ end }}
                {{ end }}
            </ul>

The gallery itself works fine. What I would like to do is add the filename of the image without the file extension in the last paragraph tag. What I have clearly doesn’t work, but I’m not really sure the proper direction on making it work. Any help would be greatly appreciated!

{{ strings.TrimSuffix (path.Ext .Name) .Name }}

References:

10 Likes

Thank you!!!

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