I would like to process an yml file with hugo, but for now putting an yml file in /content, I end up with the same yml file in /public. With its front matter and all…
Full context :
I use NetlifyCMS to provide my customers with an admin panel.
This admin panel is provided by 2 static files : /admin/index.html and /index/config.yml.
I use two different versions of config.yml depending on environment : dev (local) or prod (gitlab pages). The only part changing is the backend: part at the begining of the file.
Thus I would like Hugo to process this config file and probably create a specific layout for the conditional part (netlifyCMS backend). The rest of the yaml content would sit directly in the /content/admin/config.yml file (this way no need to escape anything I guess…)
My big problem is it seems I can’t find a way for hugo to process my yml file. I get the exact same in the public folder with its front matter and all !
Then I’m not sure either yet on how to get the good layout (the file not being processed, I can’t test anything yet). Maybe something like /layouts/index.yml.yml ? (from what I could find in the doc concerning different file types and outputs)
My yml file / layout (I mix both for the general idea) would be something like :
---
---
{{ $url := .Permalink }}
{{ $u := urls.Parse $url }}
{{ $u.Hostname }}
{{ if eq $u.Hostname "localhost" }}
# local server ( run : npx netlify-cms-proxy-server )
backend:
name: local
local_backend: true
{{ else }}
backend:
name: gitlab
repo: crachecode/unko
branch: main
auth_type: pkce
app_id: 58a63e233ad656842e923955eabe574736bcc45ad13a48e71f1cc8a7f31760cf
{{ end }}
{{ .Content :
media_folder: assets/img
public_folder: /img
collections:
- name: 'pages'
label: 'Pages'
folder: 'content'
etc.
Seems like a very complicated setup. I place both .config.yaml and the index file in static/admin and that’s it. It just works. I don’t understand why you would need the admin panel to be different on your dev environment.
Why even use an admin panel on your local? I don’t get it. You can just edit the files directly…
Generating an yml file dynamically should not be that complicated…
I have already explained the situation : I work on netlifyCMS, I create plugins, stuff like that. And I definitely don’t use the same exact config file locally and on gitlab (it’s called a backend). Hence my message. Not everyone have the same needs !
Hugo is not treating this as a page for it’s not a mardkown file. For Hugo, this is just a file, so no template is applied, it is merely copied over as is to /public.
Now try and use the md extension for it be to be processed as a page and applied a template etc…
But be aware that your current yaml output format template is for the homepage alone (index.yaml.yml), for it to be applied to a page you should rename it to single.yaml.yml and move it to the layouts/_default folder.
Also, remove the following from your project configuration file:
outputs:
home:
- html
- yaml
And add this to the frontmatter of your content/admin/config.md