Hugo Could not render org

Sometimes when building my hugo blog, it will fail and display error:

ERROR 2023/02/12 08:48:55 Could not render org: could not write output: runtime error: invalid memory address or nil pointer dereference. Using unrendered content.

I originally wrote in markdown format, now in Org-mode. So there are two types of files in my content folder.

I use latest hugo(v0.110.0), my blog repo GitHub - tianheg/blog: Blog Source Files

Hugo source code related with the error log: hugo/convert.go at 9af78d11003ed22b6281e47e1ac19568cf1cca81 · gohugoio/hugo · GitHub

Have searched GitHub issues, found some error logs have invalid memory address or nil pointer dereference, but not because org files

❯ neofetch --off          
archie@arch
-----------
OS: Arch Linux x86_64
Host: HP Laptop 14s-cr0xxx
Kernel: 6.1.10-arch1-1 
Uptime: 1 day, 17 hours, 31 mins 
Packages: 1305 (pacman) 
Shell: zsh 5.9 
Resolution: 1920x1080 
DE: Plasma 5.26.5 
WM: kwin 
Theme: [Plasma], Breeze [GTK2/3] 
Icons: [Plasma], breeze-dark [GTK2/3] 
Terminal: konsole 
Terminal Font: Monospace 12 
CPU: Intel i5-8250U (8) @ 3.400GHz 
GPU: Intel UHD Graphics 620 
GPU: AMD ATI Radeon R7 M260/M265 / M340/M360 / M440/M445 / 530/535 / 620/625 Mobile 
Memory: 9225MiB / 23923MiB

Netlify deployment logs:

Could someone help me with this problem?

Doesn’t anyone have a problem with that?

I am not familiar with Go.

When I clone and build your site:

content/posts/a-drop-of-water.org:1:1": EOF looking for end TOML front matter delimiter

image

After I fix that problem, your site builds without errors.


                   |  EN   
-------------------+-------
  Pages            | 1019  
  Paginator pages  |    0  
  Non-page files   |    0  
  Static files     |  361  
  Processed images |    0  
  Aliases          |    0  
  Sitemaps         |    1  
  Cleaned          |    0  

Total in 9400 ms

Sorry for this error, I was converting md into org. Not related with Could not render org.

Could not render org error is unpredictable, here is my Netlify deploy page:

Let’s select one Failed, see its details(link):

10:14:44 PM: > hugo --gc --buildFuture
10:14:44 PM: Start building sites …
10:14:44 PM: hugo v0.111.0-3fa8bb8318114cd69315eadd35bda169e6a8ca4b+extended linux/amd64 BuildDate=2023-03-01T20:57:44Z VendorInfo=gohugoio
10:14:45 PM: ERROR 2023/03/08 14:14:45 Could not render org: could not write output: runtime error: invalid memory address or nil pointer dereference. Using unrendered content.
10:14:48 PM: Error: Error building site: logged 1 error(s)
10:14:48 PM: Total in 3463 ms

It happens sometimes locally

When did this start happening?

From 2022-12-14 (deploy log), I was using Hugo v0.107.0, repo state. Because I modified git author/email, so if you want to clone the repo, from this repo state, not the netlify deploy page.

This is the earliest I can find. I can’t remember the earlier mistakes.

I built your site about 500 times, and I saw the error twice. I have no idea how to consistently reproduce the problem.

Thank you for your kind help. It seems that we can only temporarily set aside this issue for now.

When you build your site on Netlify, your build script calls pnpm run all.

package.json

"pagefind": "./pagefind --source public --bundle-dir ../static/_pagefind",
"build": "hugo --gc --buildFuture",
"start": "hugo serve --buildFuture --disableFastRender --renderStaticToDisk",
"all": "npm-run-all build pagefind build"

Is there a reason you are building your site twice?

I’ve used pagefind, and the sequence was (a) build the site, then (b) run pagefind.

I’m asking because in one of the logs the first build was fine, but the second build (after running pagefind) failed.

  1. First build, I put content into public as usual
  2. Run pagefind, source is public, export to static/_pagefind
  3. Second build, put static/_pagefind to public folder

When hugo serve locally, errors display sometimes:

ERROR 2023/03/09 13:55:35 Could not render org: could not write output: runtime error: unsafe.String: len out of range. Using unrendered content.

This is a different error

It seems like you’re wasting build minutes when you can do:

hugo --gc --minify
pagefind --source public

That’s what I do.

You are right, I don’t need to do that on Netlify.

Now I figured that, I done this because only build one time don’t work locally.

@kaushalmodi Have you seen either of these intermittent errors before?

ERROR 2023/03/08 14:14:45 Could not render org: could not write output: runtime error: invalid memory address or nil pointer dereference. Using unrendered content.

ERROR 2023/03/09 13:55:35 Could not render org: could not write output: runtime error: unsafe.String: len out of range. Using unrendered content.

I haven’t, at least for the few times I’ve tried out Hugo’s native Org parsing.

@tianheg This looks like a bug in the Go Org parsing package used by Hugo. I suggest posting an issue on GitHub - niklasfasching/go-org: Org mode parser with html & pretty printed org rendering. also shitty static site generator. with a minimal reproducible example.

1 Like

Yeah, that’s the hard part… 500 builds surfaced the error twice. Thanks for having a look.

I created an issue Hugo Could not render org · Issue #99 · niklasfasching/go-org · GitHub

Upgrade Hugo version to 0.111.3 can solve this problem. Details here: Fix race condition surrounding global orgWriter · niklasfasching/go-org@5464ab3 · GitHub

1 Like

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