Different behavior locally vs on netlify

This code excludes alltaxa and archive in the navbar menu as expected locally (hugo server) but not on netlify (https://merodemo.netlify.com/). I am using the same hugo version (0.55.6) in both case. What could be the reason?

The repo for theme is https://github.com/darshanbaral/mero and for demo is https://github.com/darshanbaral/merodemo.

<ul class="list-unstyled">
  {{ range .Site.Sections.ByWeight }}
  {{ $thisSection := replace .File.Dir "\\" "" }}
  {{ if not (in (slice "alltaxa" "archive") $thisSection) }}
  <li class="pt-2">
    <a href="{{ .Permalink }}">{{ .Title }}</a>
  </li>
  {{ end }}
  {{ end }}
</ul>

Are you sure it works locally?

I cloned your repo and submodule, ran hugo server -D and the dropdown menu had four entries in it: Posts, Blogs, Archive, and taxa (Hugo 0.55.6). From your description and code, I assume you’re not wanting the last two to be in this dropdown menu.

Does this thread help—Exclude section from list?

1 Like

Are you on Linux or macOS by any chance @funkydan2 . I tried testing on another computer again and am having the same issue. So far I have tested in Windows 7 and Windows 10.

Aah, yes I am. I wonder if the problem is with case sensitivity. AFAIK, Windows filesystems are case insensitive, whereas Linux and Mac normally are.

I’ve not used the .File functions, so I’m not sure how case affects it.

1 Like

It’s a file path separator issue. Had to change from

{{ $thisSection := replace .File.Dir "\\" "" }}

to

{{ $thisSection := replace (replace .File.Dir "\\" "") "/" "" }}

I guess replaceRE would work too.

1 Like