Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Image resource .Title defaulting to filename? #5609

Closed
tashian opened this issue Jan 15, 2019 · 5 comments
Closed

Image resource .Title defaulting to filename? #5609

tashian opened this issue Jan 15, 2019 · 5 comments
Labels

Comments

@tashian
Copy link

tashian commented Jan 15, 2019

I'm not sure if this is a docs issue or a bug.

In the docs for Page Resources, the default Title property value is stated as blank

But in v0.53, when I don't supply a title for a resource in the front matter, the default value of .Title for the resource seems to be the filename of the resource. In my case, I'm using title as a way of specifying cover image captions, and I'd like for it to be blank by default.

Here's the template code I'm using for my cover images:

    {{ $img := (.Resources.ByType "image").GetMatch "cover" }}
    {{ with $img }}
      <figure>
          {{ $big := .Resize "1232x" }}
          {{ $small := $big.Resize "616x" }}
          <img srcset="{{ $small.RelPermalink }} 1x, {{ $big.RelPermalink }} 2x" alt="{{ $img.Title }}" width="{{ $big.Width }}"  class="mw-100">
          <figcaption>{{ $img.Title }}</figcaption>
      </figure>
    {{ end }}
@bep
Copy link
Member

bep commented Jan 15, 2019

I'm not sure if this is a docs issue or a bug.

I'm pretty sure the Title has always had this default value.

/cc @regisphilibert

@regisphilibert
Copy link
Member

Mmm... In my blog post which is anterior to the doc, I mention .Title and .Name both default to the base filename. Not sure why the doc says different considering I wrote it way back when but this should be fixed indeed.

In any case your test before outputing $img.Title could be as simple as:

{{ if not eq .Name .Title }}
I have a custom Title
{{ end }}

regisphilibert added a commit to gohugoio/hugoDocs that referenced this issue Jan 15, 2019
@regisphilibert
Copy link
Member

Done: https://gohugo.io/content-management/page-resources/

This can be closed.

@tashian
Copy link
Author

tashian commented Jan 15, 2019

Yay! Thanks. :D

@tashian tashian closed this as completed Jan 15, 2019
bep added a commit that referenced this issue Feb 1, 2019
49809a03 Merge commit '20a631b4964fc0ab9137cce1e41774cbc17de044'
20a631b4 Squashed 'themes/gohugoioTheme/' changes from b8202f539..dafc91ff1
8b58f565 Re-generate CLI docs
4653a724 Add Netlify deployment badge
2d6246bc Remove some deprecated site variables
e6777153 Improve Algolia Search Display Styling
1570999f Add missing "." in front of gitlab-ci.yaml example
b922ae7d This adds documentation to the new configDir/Environment logic from .53 (#729)
7cff379f Correctly escape multi-word taxonomy terms in example
2dfeeda4 fix typo by removing stray paren
0870bd9a Fix typo in `paginate` description
91e8be85 Fixes #5609
c1db65ec Make the dummy URL more obvious
b4589ff0 Fix a link
b73dcb9a Consistently use "posts" as section name in examples
7a56abbc Format definitions
a9c6fd9b Minor clarification over the last commit
5c86bdc8 Add alternative instructions for Quick Start for non-git users
dafe7ee9 Add Visual Studio Code plug-ins
110ed19e Update HUGO_VERSION
2abd031a Update page.md
b332f7b9 Update page.md
f5a8c9d4 Update static-files.md
6d0c155c Add note about relative protocol URLs
a13751ac Theme Warning: Remove note about unquoted URLs
4c8f7d68 Incorporate feedback
6f2b9cf0 Update Creating Themes Warning
40d88d98 Fix ToC example to use binary true/false
4a11f3f1 Fix typo
2dbfc0a4 Fix a typo in taxonomies
d63790ef Do not mark UndocumentedFeature issues as stale
d7aff095 Regenerate docs.json
71c0826f Update transform.Unmarshal.md

git-subtree-dir: docs
git-subtree-split: 49809a038b2691637bab7f3f2e385dde654a88b8
@github-actions
Copy link

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Feb 21, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

3 participants