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

Tagcloud getting: 'executing "index.html" at <.Name>: can't evaluate field Name in type hugolib.WeightedPages' #318

Closed
mpas opened this issue Jun 4, 2014 · 10 comments
Milestone

Comments

@mpas
Copy link

mpas commented Jun 4, 2014

I am trying to build a tag cloud in the index.html and using the example given in the docs.

Tags

{{ range .Site.Taxonomies.tags }}
{{ .Name }}
{{ end }}

But whenever i do this i get an error:
'executing "index.html" at <.Name>: can't evaluate field Name in type hugolib.WeightedPages'

Am i missing something?

Cheers Marco

@spf13
Copy link
Contributor

spf13 commented Jul 1, 2014

I think the example is out of date and needs to be updated.

@curiouslychase
Copy link
Contributor

Is tags a Map of maps instead of a slice of maps?

{{ range $key, $val := .Site.Taxonomies.tags }}
  Tag Name: {{ $key }}
  Array of Pages: {{ $val }}
{{ end }}

That worked for me, but I'm not sure what I'm missing and I'm really curious to know what's happening. Is the Taxonomystruct in taxonomy.go what's creating .tags?

@spf13
Copy link
Contributor

spf13 commented Aug 29, 2014

Yes. I was actually writing documentation for it tonight and in doing so it made me think to change a couple things. Stay tuned.

@tgirod
Copy link

tgirod commented Aug 30, 2014

Regarding #449, This doesn't change the fact that .Site.Taxonomies.mytaxonomy.mykey returns a list of WeightedPage

@spf13
Copy link
Contributor

spf13 commented Aug 30, 2014

@tgirod... sorry, I don't follow. Are you suggesting that it should return a list of Pages instead?

@tgirod
Copy link

tgirod commented Aug 31, 2014

As I explained #449, I am trying to list all the pages with a spectific key "lea" in taxonomy "artistes". To do so, I follow the second example in taxonomies/displaying:

{{ range .Site.Taxonomies.artistes.lea }
{{ .Name }}
{{ end }}

There, I get WeightedPages - they don't have a Name field, so the code from the example doesn't work. From there, I am wondering how I could achieve my goal.

@s17t
Copy link

s17t commented Nov 1, 2014

I confirm @tgirod problem. The second example in taxonomies/displaying doesn't work.

{{ range .Site.Taxonomies.series.trippyhacks }
{{ .Name }}
{{ end }}

raise error:

ERROR: 2014/11/01 Error while rendering page post/seventh.md: template: theme/post/single.html:27:24: executing "theme/post/single.html" at <.Name>: Name is not a field of struct type hugolib.WeightedPage

using 0.13-DEV

@dvdsgl
Copy link

dvdsgl commented Aug 20, 2015

Similarly, I am trying to list my guides:

{{ range .Site.Sections.guides }}
  <li>"{{ .Title }}"
{{ end }}

But .Title isn't valid on WeightedPage. How do I get at the page representation?

@dvdsgl
Copy link

dvdsgl commented Aug 20, 2015

I've tried:

{{ range .Site.Sections.guides }}
  <li>"{{ .Page.Title }}"
{{ end }}

But I just get empty strings.

@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 Apr 13, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

6 participants