Hi there,
Only recently using Hugo but really appreciate speed, design and ease of use so far! I am struggling with one particular bit though. I did read the documentation many times and scouted this forum for similar topics but nothing seems to apply.
- A site is deployed to Netlify and I want to provide support for NetlifyCMS which allows users to add/edit pages from Netlify user interface
- This requires creating 2 files in the /admin folder of the generated static site, that is
/public/admin/index.html
and/public/admin/config.yml
-
/public/admin/index.html
is purely static and I can simply add it to /content/admin/index.html (I could also use /static/… for that) -
/public/admin/config.yml
however has a few elements that needs to be taken from the Hugo site root config.yml file
And so the config.yml file should be built like a page, using go templates and variables from the .Site config. Example:
# Netlify CMS configuration for use with ClearStatus backend:
name: git-gateway
branch: {{ .Site.Params.repoBranch }}
Output formats should do that fine but it’s not working for me now. Here is what I’ve done:
- Created /content/admin/config.md with only front matter:
---
title: "Netlify config file"
date: 2019-04-11
outputs:
- netlifyyaml
---
- In root hugo config.yml, added:
mediaTypes:
application/netlifyconfig:
suffixes:
- "yml"
outputFormats:
netlifyyaml:
isPlainText: true
isHTML: false
mediaType: "application/netlifyconfig"
notAlternative: true
- in /layouts/admin, I added a template called single.netlifyyaml.yml
Now when I run hugo on this configuration:
- /public/admin/index.html is copied as is from /content/admin/index.html as expected
- BUT: the /public/admin/config.yml is NOT created.
Other details:
- the template single.netlifyyaml.yml seems to be used/parsed because if I voluntarily introduce an error in it, Hugo stops and output the error
- I also tried adding the template to /layouts/_default/single.netlifyyaml.yml, /public/admin/config.yml is not created.
Any pointer?
Many thanks