Problem with rendering a partial (it just copies itself into html as text)

I wanted to add a code, that would list all my albums on my websitecom/music/
But when I added this code

{{ range where .Site.RegularPages "Tags" "album" }}
	<li><a href="{{ .RelPermalink }}">{{ .Title }}</a></li>
{{end}}

It didn’t even show me some kind of error, it just… pasted it… into html itself.

<div id="categories-3" class="widget widget_categories">
		<h3>Альбомы</h3>
		
			{{ range where .Site.RegularPages "Tags" "album" }}
				<li><a href="{{ .RelPermalink }}">{{ .Title }}</a></li>
			{{end}}
</div>

And now I’m really confused. Can’t find anything about this error, because, well, I can’t figure out the name of this error.
My files are structured like this:

  • content
    • music
      • index.html ← code is here
      • holyshot.html ← album that has an “album” tag

To be honest, I’m an amateur, and I learned this HUGO thingy by trial and error. So if the solution is really simple – just tell me what I should read about, and I’ll do it myself. I can’t even check if this code is correct, because it does nothing rn

It sounds like you are placing template code in a content file. Template code goes in template files.

You are more likely to receive a prompt and accurate response if you post a link to your project’s Git repository.

See Requesting Help.

Let us see your code

Include a link to the source code repository of your project, because we really need the context of seeing your templates and partials to be able to help you. It is trivial to do a quick git clone on your repo, then run hugo server in your project, to help you out. On the other hand, recreating your code from screenshots, or sort of guessing at it, is not.

If you can’t share your repository for whatever reason, consider creating a dummy repo that you can share, which reproduces the problem you’re experiencing.

Thanks, that info was enough for me to figure this out. I created a partial with the code I needed and now it works… sometimes. But that will be enough for now. :folded_hands:
Maybe in the future I’ll open git repo for my website, cuz I still need help with some things, but not now

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