You are correct in those two approaches, but there is something worth mentioning. For the 'Use this Page Schema as Metadata Schema' approach you don't have to use an Embeddable Schema, you could achieve the same thing by adding non-nested fields into the Region Schema (representing the Page Schema).
Both options comes in Razor view back as dictionary e.a. @Model.Meta["publishdate"] You have to check fields before usage.
True, the Page Model always has a Meta
property in the form of a dictionary, which provides you with a non-strongly typed option.
Question-1: How to implement strong name for Metadata Schema?
See Custom Page Models. Now truth be told, the
You can map the metadata fields of the Page to Page Model properties by using the same model mapping mechanism used for Entities.
is not really helpful because (assuming Regular Mode (not Retrofit)) Entities rely on the Root Element Name of a Schema, whilst Metadata or Region (Page) Schemas don't have said property. For them, the correct way is described here.
Note the following:
The Title field (alphanumeric characters only) of the Schema, if the Schema is a Multimedia Schemas or a Metadata Schemas "
Now back to your questions:
Question-2: What is the way to go to collect metadata at page level?
There is no right approach, though I tend to use the custom Page Model method. It's more powerful and flexible.
- General (embedded) metadata schema is added to each page schema. Works OOTB.
What's the question here? As stated earlier, you don't need an Embedded Schema.
- Add metadata to components and extract that to page level. How to do that? OOTB?
Through Semantic Mapping as explained for Question-1. Same way like when you have a Component Link inside of your Entities
- Add metadata to Structure Group and get that in metadata with the pages. OOTB? Some field should be added for Page as metadata it self.
See the Model Builder Pipeline here. And the InheritMetadataPageModelBuilder here.
A model builder that adds metadata of the Structure Group containing the Page, or one of its parents, to the current Page
Now I haven't used it in a while, but IIRC, it behaves exactly the way you need to. If not, you can always create you own Model Builder and populate the Metadata on the CM side as needed.
UPDATE
It's exactly the same as for Entity Models, the only trick is to get the SemanticEntity
Attribute correct. Example of a custom Page Model:
[SemanticEntity(EntityName = "TitleOfTheMetaOrPageSchemaNoSpacesSpecialCharactersRemoved")]
public class MyCustomPageModel : PageModel
{
public MyCustomPageModel() : base() { }
public MyCustomPageModel(string id) : base(id) { }
[SemanticProperty("myCustomPropertyXmlName")]
public string MyCustomProperty { get; set; }
}