There are two basic ways to approach this: directly, by creating explicit documents with the relevant layout, or indirectly, by customizing your chosen compile format to do this work for you. In either case, you will want to learn about Scrivener placeholders. Scrivener has a fairly extensive set of placeholders you can use. For example, where the string <$title> appears in your text, Compile will replace it with the name of the document that text appears in. Similarly, <$parenttitle> will be replaced by the name of the parent container of that document.
A list of available placeholders can be found under the Help menu on macOS. Also, you will find placeholders that can be used to auto-number your chapters.
If you use the direct approach, you will need your Compile format to respect the formatting you set for your chapter starts.