netlify - Netlify CMS 图像上传到错误的媒体文件夹
问题描述
这是我的 Netlify CMS 的 config.yml
backend:
name: git-gateway
branch: master
repo: franva/askwinston
commit_messages:
create: 'Create {{collection}} “{{slug}}”'
update: 'Update {{collection}} “{{slug}}”'
delete: 'Delete {{collection}} “{{slug}}”'
uploadMedia: '[skip ci] Upload “{{path}}”'
deleteMedia: '[skip ci] Delete “{{path}}”'
media_folder: static/img
public_folder: /img
publish_mode: editorial_workflow
local_backend: true
collections:
- name: "blog"
label: "Blog"
folder: "src/pages/blog"
create: true
media_folder: static/img
public_folder: /img
slug: "{{year}}-{{month}}-{{day}}-{{slug}}"
fields:
- {label: "Template Key", name: "templateKey", widget: "hidden", default: "blog-post"}
- {label: "Title", name: "title", widget: "string"}
- {label: "Publish Date", name: "date", widget: "datetime"}
- {label: "Description", name: "description", widget: "text", required: false}
- {label: "Featured Post", name: "featuredpost", widget: "boolean", required: false}
- {label: "Featured Image", name: "featuredimage", widget: image, required: false}
- {label: "Body", name: "body", widget: "markdown"}
- {label: "Tags", name: "tags", widget: "list"}
- name: "pages"
label: "Pages"
create: true
files:
- file: "src/pages/index.md"
label: "Landing Page"
name: "index"
fields:
- {label: "Template Key", name: "templateKey", widget: "hidden", default: "index-page"}
- {label: Title, name: title, widget: string}
- {label: Image, name: image, widget: image}
- {label: Subheading, name: subheading, widget: string}
- {label: Mainpitch, name: mainpitch, widget: object, fields: [{label: Description, name: description, widget: text}]}
- {label: Intro, name: intro, widget: object, fields: [{label: Heading, name: heading, widget: string}, {label: Description, name: description, widget: text}, {label: Blurbs, name: blurbs, widget: list, fields: [{label: Image, name: image, widget: image}, {label: Text, name: text, widget: text}]}]}
- {label: Main, name: main, widget: object, fields: [{label: Heading, name: heading, widget: string}, {label: Description, name: description, widget: text}, {label: Image1, name: image1, widget: object, fields: [{label: Image, name: image, widget: image}, {label: Alt, name: alt, widget: string}]}, {label: Image2, name: image2, widget: object, fields: [{label: Image, name: image, widget: image}, {label: Alt, name: alt, widget: string}]}, {label: Image3, name: image3, widget: object, fields: [{label: Image, name: image, widget: image}, {label: Alt, name: alt, widget: string}]}]}
- file: "src/pages/about/index.md"
label: "About"
name: "about"
fields:
- {label: "Template Key", name: "templateKey", widget: "hidden", default: "about-page"}
- {label: "Title", name: "title", widget: "string"}
- {label: "Body", name: "body", widget: "markdown"}
如您所见,我已将 Media 和 Public 文件夹分别设置为 rootstatic/img
和/img
collections 级别。
但是当我从管理员博客编辑器上传文件时,它仍然会将图像更新到
文件夹/root/src/pages/blog/static/img
而不是/root/static/img
文件夹。
解决方案
您应该删除 Blog 集合下的这些行:
media_folder: static/img
public_folder: /img
推荐阅读
- javascript - 如何在 OpenWeather 的 api url 中使用模板字符串
- css - SWUP 更改 CSS 文件和动画淡入效果 (HeadPlugin)
- python - Webdriver:未定义的名称“驱动程序”
- python - 如何在没有硒的情况下抓取动态网站
- javascript - 将代码粘贴到 Gist 后丢失格式
- r - R随机化和随机化数据表的列
- python - 如何计算每日用户差异并重塑熊猫数据框?
- linux - 如何从 github repo 创建一个 linux shell 命令?
- php - codeigniter 4 电子邮件未发送
- android - Android Studio 和 Gradle:“构建失败,出现异常。”