Reputation: 2076
I am just getting started with Netlify CMS and I am confused how to update the CMS once my admin/config.yml
changes
I cloned the default Hugo project and I modified some of the config.yml
file fields for the home page and wired them up correctly in the index.html. The generated static file looks correct.
However, when I go to the CMS (/admin
), I only see the old index.html content (in the CMS Preview section). So I renamed the js
folder and copied only the app.js
file into a fresh js
folder. But that breaks things saying cms.js
is missing. I added the old one but it did not pick up the cms-preview-templates
.
I thought all of this will get generated from the config.yml
.. Do I need to manually edit the JS files to setup the CMS? Or is it possible to regen all the files once config.yml
and the associated html files change?
The help page on setting up your own site does not say much about editing the template.
Update
I see cms.js
file has some content like this:
import HomePreview from "./cms-preview-templates/home";
import PostPreview from "./cms-preview-templates/post";
import ProductsPreview from "./cms-preview-templates/products";
import ValuesPreview from "./cms-preview-templates/values";
import ContactPreview from "./cms-preview-templates/contact";
and when I go check these files (master
branch), they have the content from the original sample project and does not have the changes I made. What do I need to do to automatically update these template files as I make changes to my site (corresponding changes are in the admin/config.yml
file)?
Thanks!
Upvotes: 2
Views: 1240
Reputation: 819
You can use netlify-cms-proxy-server
for local development.
Edit your config.yaml to add a local_backend
field like so
backend
name: git-gateway
# important bits here
local_backend: true
...
Then, in the project's directory, start netlify-cms-proxy-server
npx netlify-cms-proxy-server
Start your local development server, and you should be good to go
# note: may be different depending on your project's configuration
hugo server -D
For more details, check out netlify-cms's docs on working with a local git repo.
Upvotes: 0
Reputation: 14353
Making changes local in the project content will not be reflected in NetlifyCMS
until you push those changes to the repository. The default config.yml
setup does not include a local workflow because it does not have a local file system backend at this time.
Changes to the admin/config.yml
will work locally, but expects the content data changes in the location of your backend configuration.
Example:
The following config will be looking for changes on GitHub
in the master
branch of netlify/netlifycms-example
repository.
admin/config.yml
backend:
name: github
repo: netlify/netlifycms-example
branch: master
Update: When you make changes to the config.yml
and change the templates in your site generator, you will also need to make those changes inside the preview template code for the cms to display your data correctly in the previews.
Upvotes: 1