I’ve got a few parameters that I would like to easily generate and not have to handle in other parts of the code. It would be helpful if I could create them “on the fly” to speak in the frontmatter.
For example, in frontmatter I have a parameter named “Year” and a parameter named “City”. I also need to create a reference to the data file associated with the year and city, which is currently stored as a parameter called “eventname”, which would be yyyycity.
Ideally, that parameter could be created in the frontmatter on the fly. I suppose the workaround would be everywhere I need to access that value I could construct it based upon the city and year, but being able to generate parameters based on other frontmatter parameters would be helpful. Am I missing something?
Basically, what I’m trying to do is build something inside the frontmatter. So the user creating the content file (the event owner, in this case) would add the “City” and “Year” fields…I would like it to be able to construct the “eventname” field based upon the “City” and “Year” parameters.
I’ve already kind of figured out I’m better off doing this in the code itself. Although I’m finding that cities with spaces in their names causes me agita, but that’s another story
This issue can probably be closed.
Sounds like you would need to preprocess the info before the .md content file is created to get that functionality to work. Like running a task before the hugo command so that the correct directory structure was created, otherwise I’d suggest that you use urlize on your city parameter.
I could see you using ‘printf’ to combine these two parameters and have them point to a file in data;i.e., unless the goal is to have the newly generated metadata travel with the yaml/document, in which case I would write a bash script to append those two values in the head of each content/md file, but this strikes me as gratuitous if you can discern C by looking at A and B in a markdown file’s frontmatter. Is the idea that the newly generated value will then point to another dataset somewhere else?