0

I'm having an issue with file paths on the Netlify CMS on the live site, everything worked fine whilst on localhost. U have the following in my config.yml:

backend:
  name: git-gateway
  branch: main
  repo: [my-repo]
media_folder: "src/img"
public_folder: "/img"
collections:
  - name: "guides"
    label: "Guides"
    folder: "/src/guides"
    create: true
    delete: true
    fields:
    // Some fields removed for brevity
      - { label: "Body", name: "body", widget: "markdown" }

I can create a new post (guide) absolutely fine, I have several other collections which all also work fine, the issue is with the images. I can upload images and they're added to my img folder, but the path is incorrect, as an example, if I choose an image from the media library and then toggle the markdown editor view, I get:

![Alt test](/src/img/logo--dark.png)

which then throws a deploy error, with the issue:

ENOENT: no such file or directory, stat '/src/img/logo--dark.png' (via Error)

Which is easy enough to understand, as the correct path should be:

![Alt test](./src/img/logo--dark.png)

My site structure is straightforward (Eleventy is doing the magic in the background):

public
-img
...
-guides
-- guide-1.html
...
src
- img
...
- guides
-- guide-1.md

I'm missing the period before the filepath in the markdown editor and changing the media-folder filepath isn't solving the issue. So the question is, when a user uploads an image in the CMS how do I get the editor to create the correct filepath?

Daz Lee
  • 144
  • 1
  • 9

0 Answers0