update schema handling and add docs entry for it
This commit is contained in:
parent
4d130a90b7
commit
9bd7b0ba10
5 changed files with 61 additions and 5 deletions
|
|
@ -1,5 +1,5 @@
|
|||
<!-- inline base schema -->
|
||||
{% include "schemas/base-schema.njk" %}
|
||||
{% include "schemas/WebSite.njk" %}
|
||||
|
||||
<!-- inline blogpost schema -->
|
||||
{% if schema == 'blog' %}{%- include "schemas/blogpost-schema.njk" -%}{% endif %}
|
||||
{% if schema %}
|
||||
{%- include "schemas/" + schema + ".njk" -%}
|
||||
{% endif %}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
---
|
||||
layout: base
|
||||
schema: blog
|
||||
schema: BlogPosting
|
||||
---
|
||||
|
||||
<article class="region" style="--region-space-top: var(--space-xl-2xl)">
|
||||
|
|
|
|||
56
src/docs/schema.md
Normal file
56
src/docs/schema.md
Normal file
|
|
@ -0,0 +1,56 @@
|
|||
---
|
||||
title: Schema
|
||||
---
|
||||
|
||||
Schema markup provides additional context for search engines and screen readers. The main schema template is included in the `<head>` via `src/_includes/head/schema.njk`. New schemas should be placed in `src/_includes/schemas/`.
|
||||
|
||||
To use the "BlogPosting" schema, set the schema key in the front matter:
|
||||
|
||||
```yaml
|
||||
---
|
||||
schema: BlogPosting
|
||||
---
|
||||
```
|
||||
|
||||
To use an Event schema for example, create a template at `src/_includes/schemas/Event.njk`, with something similar to:
|
||||
|
||||
{% raw %}
|
||||
|
||||
```jinja2
|
||||
<script type="application/ld+json">
|
||||
{
|
||||
"@context": "http://schema.org",
|
||||
"@type": "Event",
|
||||
"location": {
|
||||
"@type": "Place",
|
||||
"address": {
|
||||
"@type": "PostalAddress",
|
||||
"addressLocality": "{{ event.data.place.city }}",
|
||||
"postalCode": "{{ event.data.place.plz }}",
|
||||
"streetAddress": "{{ event.data.place.street }}"
|
||||
},
|
||||
"name": "{{ event.data.place.name }}"
|
||||
},
|
||||
"name": "{{ event.data.title }}",
|
||||
"description": "{{ event.data.description }}",
|
||||
"startDate": "{{ event.data.date }}",
|
||||
"performer": "{{ event.data.artist }}"
|
||||
}
|
||||
</script>
|
||||
```
|
||||
|
||||
{% endraw %}
|
||||
|
||||
And reference it in the front matter:
|
||||
|
||||
```yaml
|
||||
---
|
||||
schema: Event
|
||||
---
|
||||
```
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
Loading…
Reference in a new issue