Hugo is creating unnecessary files

Hi all

I am trying to generate jsx files from my content using hugo output formats.

$hugo env
hugo v0.85.0+extended linux/amd64 BuildDate=unknown
GOOS="linux"
GOARCH="amd64"
GOVERSION="go1.16.5"

my config.toml file

disableKinds = ["rss" , "page", "section" , "term", "taxonomy" ]

[outputs]
  page = ["jsx"]
  home = ["jsx"]
  section = ["jsx"]
  term = ["jsx"]
  taxonomy = ["jsx"]

[outputFormats.jsx]
  isPlainText = true
  notAlternative = true
  mediaType = "text/jsx"
# relevant list.jsx.jsx

{{- ""}}
{{ $.Scratch.Set "idx" 0 }}
{{- $.Scratch.Add "jsxPages" slice }}

{{- range .Site.RegularPages.ByDate.Reverse }}
{{- $.Scratch.Set "idx" (add ($.Scratch.Get "idx") 1) }}

{{- $.Scratch.Add "jsxPages"
  ( dict
    "idx" ($.Scratch.Get "idx")
    "link" .RelPermalink
    "path" ( substr .RelPermalink 9 ( sub (len .RelPermalink) 19 ) )
  )
}}
{{- end -}}

{{- ""}}
const pagesMap = new Map([
{{- range $.Scratch.Get "jsxPages" }}
  ["/{{.path}}",lazy(()=> import("../site{{.link}}"))],
{{- end }}
]);

{{/* */}}
{{- $sortedPages := .Site.RegularPages.ByDate.Reverse }}
{{ $paginator := .Paginate $sortedPages 2 }}
{{ range $paginator.Pagers }}
  //{{ .PageNumber }}
  {{ range .Pages }}
    //{{ .Title }}
  {{ end }}
{{ end }}

when i run hugo --gc --minify here are the files i see that are getting generated:

$find site-hugo/public/ -path "*/page/*"
site-hugo/public/series/walking-down-memory-lane/page/2
site-hugo/public/series/walking-down-memory-lane/page/2/index.jsx
site-hugo/public/series/walking-down-memory-lane/page/3
site-hugo/public/series/walking-down-memory-lane/page/3/index.jsx
site-hugo/public/series/wiring-data-transformations-for-speed/page/2
site-hugo/public/series/wiring-data-transformations-for-speed/page/2/index.jsx
site-hugo/public/series/wiring-data-transformations-for-speed/page/3
site-hugo/public/series/wiring-data-transformations-for-speed/page/3/index.jsx
site-hugo/public/series/page/2
site-hugo/public/series/page/2/index.jsx
site-hugo/public/series/page/3
site-hugo/public/series/page/3/index.jsx
site-hugo/public/2017-09/page/2
site-hugo/public/2017-09/page/2/index.jsx
site-hugo/public/2017-09/page/3
site-hugo/public/2017-09/page/3/index.jsx
site-hugo/public/page/2
site-hugo/public/page/2/index.jsx
site-hugo/public/page/3
site-hugo/public/page/3/index.jsx
site-hugo/public/2013-07/page/2
site-hugo/public/2013-07/page/2/index.jsx
site-hugo/public/2013-07/page/3
site-hugo/public/2013-07/page/3/index.jsx
site-hugo/public/tags/page/2
site-hugo/public/tags/page/2/index.jsx
site-hugo/public/tags/page/3
site-hugo/public/tags/page/3/index.jsx
site-hugo/public/tags/memory/page/2
site-hugo/public/tags/memory/page/2/index.jsx
site-hugo/public/tags/memory/page/3
site-hugo/public/tags/memory/page/3/index.jsx
site-hugo/public/tags/dataflow/page/2
site-hugo/public/tags/dataflow/page/2/index.jsx
site-hugo/public/tags/dataflow/page/3
site-hugo/public/tags/dataflow/page/3/index.jsx
site-hugo/public/popular/page/2
site-hugo/public/popular/page/2/index.jsx
site-hugo/public/popular/page/3
site-hugo/public/popular/page/3/index.jsx
site-hugo/public/popular/top00/page/2
site-hugo/public/popular/top00/page/2/index.jsx
site-hugo/public/popular/top00/page/3
site-hugo/public/popular/top00/page/3/index.jsx
site-hugo/public/popular/top01/page/2
site-hugo/public/popular/top01/page/2/index.jsx
site-hugo/public/popular/top01/page/3
site-hugo/public/popular/top01/page/3/index.jsx
site-hugo/public/2014-09/page/2
site-hugo/public/2014-09/page/2/index.jsx
site-hugo/public/2014-09/page/3
site-hugo/public/2014-09/page/3/index.jsx

My question:

  1. why are page/2 and page/3 getting consistently generated ?
  2. how do i make sure only one .jsx file (in public/index.jsx) is generated from lists.jsx.jsx ?

Disable pagination.

Does that mean my above code will still work ? i still want to call .Paginate in my list.jsx.jsx. And can you kindly tell me how i would go about turning off pagination … i am stil lgoogling that :slight_smile:

Without access to the public repository for your project, I would just be guessing.

See https://discourse.gohugo.io/t/requesting-help/9132

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

I was confused at first but then i re-read what you wrote and i think what you are saying (IIUC) is don’t use pagination. When i comment that block of code that is using .Paginate then the problem goes away.

To me this seemed like a bug because i did not expect that to happen. I am understanding now that this is normal behaviour in hugo.

Thank you so much for your help.