How to write if not statement for two params

I try to revert the order of the following statement in my list.html so that the links subpages will be rendered before the other pages:

{{ range .Pages}}
{{if .Title }}
   {{if .Content}}
       <a href="#{{ cond (in (.Title|urlize) "%") (.Title | base64Encode) (.Title) | urlize }}">{{ .Title }}</a>
  {{ else }}
      <li><a href="{{ .Permalink }}">{{ .Title }}</a></li>
{{ end }}
{{ end }}
{{ end }}

I try to use

{{ if not (.Title) }}
{{ if not (.Content) }}

But this ends in listing no pages at all. So cause of my lacking coding skills I would be happy for some hints what to do :wink:
And sorry if failed to give all needed information.

The sequence in which the pages are rendered is determined by the collection through which you are ranging, not by conditional statements within the range block.

Imaging a deck of playing cards. No matter what you decide to do with the second card in the deck, it will always be the second card in the deck. You need to stack the deck before you start playing.

It sounds like “link” subpages have no content, so this might work for you:

{{ range (sort .Pages "Content") }}
  <h2><a href="{{ .RelPermalink }}">{{ .Title }}</a></h2>
{{ end }}

But this seems fragile to me, and makes additional sorting difficult.

It would be helpful if you were to share your project repository.


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.

1 Like

That helped especially for understanding the problem.
And it worked somehow but you are right the additional sorting is not working anymore.
the plan would be 1. blog 2. tags 3. about 4.datenschutz 5. impressum

The repo link is: Thorgrimsson / 365daysofwriting · GitLab

After examining your repository, I still do not understand your goal.

Are you simply trying to change the menu order?

yes, with the theme dimesion i use; there is no documentation on how to do this. the config files are basicly empty…
Or could i just write in in the config.yml as in other themes?
so something like:

    - identifier: 

but i think for that I need to customize the theme even more?

1) Override the theme’s list template:

cp themes/dimension/layouts/_default/list.html layouts/_default/

2) Edit layouts/_default/list.html, line 29. Change this:

{{ range .Pages.ByDate }}

To this:

{{ range .Pages.ByWeight }}

3) Edit content/blog/ Change this:

weight: 5

To this:

weight: 1

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