Image processing on homepage

Is it possible to use image processing on homepage? I have an image file content/homepage_background.jpg
I tried to add a content/_index.md file, but it says “Permission denied”. Is there a way to use image processing without a section?

We will need more info than this to help you troubleshoot. Can you share your project?

What parts do you need?

A link to the whole thing would be best. As I don’t even know if that “Permission denied” error you’re getting is hugo-related.

To answer your homepage image processing question, yes this is possible.

Given this content structure:

├───content
│       painting.jpg
│       _index.md

Then you could do something like this in your layouts/index.html template:

{{ $img := .Resources.GetMatch "painting.jpg" }}
{{ $img }}

I have realized that this is probably a Hugo bug.
The permission error was because when I try to create a content file directly under the content/ directory, it tries to create it in operating system root (/) instead of project dir.
Same behavior with newly created empty project.

Error:

  • content/_index.md
  • content/anything.md

Works:

  • content/my-posts/_index.md (it is under a subdirectory)
  • anything_other_than_content/mypost.md (automatically prepends content)

I disagree. This sounds like an issue with your particular environment setup. What OS are you using? And how are you trying to create these content files?

I am using Void Linux.
Hugo Static Site Generator v0.54.0 linux/amd64 BuildDate: unknown

How to reproduce:

hugo new site test_page
cd test_page
hugo new content/_index.md

I can access the image indeed when an _index.md file is created.
Just I had to create it with hugo new _index.md instead of hugo new content/_index.md.

Here’s your issue. This is wrong. Do it like this instead:

hugo new _index.md