I want to assign the weight of a page on build from a template in layouts. I additionally want to create a new page parameter chapter.
I have the logic to extract the value of weight and chapter working fine. They are stored in $weight and $chapter. Printing them yields expected values.
Do you mean you want to assign a page variable from a template file? You are not able to this. You can assign it to a page’s .Scratch, but you cannot update the page variable directly.
@bep, I think you misunderstood me. (Or I misunderstood you:))
I already have assigned $chapter; I extract it from the title. Since this data is already available in the title, I don’t want to manually enter it into the front matter. The value is not the same from post to post.
If it was, I would have used the cascading front matter.
Rather, I am trying to assign the chapter by extracting it using findRE and then assigning it.
I am trying to do a similar assignment with the post’s weight.