/
head_meta.html
83 lines (77 loc) · 3.88 KB
/
head_meta.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
{% load fullurl wagtailimages_tags mep_tags %}
{% comment %}
Add HTML metadata tags for unfurling, twitter preview, etc.
Uses wagtail page fields if available; uses meta_page_title,
page_description, and page_meta_image if set in context.
{% endcomment %}
{% firstof page.seo_title page.title page_title as meta_page_title %}
{% firstof page.get_plaintext_description page.search_description page_description as meta_description %}
{# keywords for meta not yet implemented in wagtail #}
{# <meta name="keywords" content="{% block meta_keywords %}{% endblock %}"> #}
{% if meta_description %}
<meta name="description" content="{{ meta_description }}"/>
{% endif %}
{# include citation information for tools like Zotero #}
<meta name="citation_publisher" content="Center for Digital Humanities, Princeton University"/>
{% if request %} {# include full url when available #}
<meta name="citation_public_url" content="{{ request.build_absolute_uri }}" />
{% endif %}
{% if page.homepage %} {# project citation on home page #}
<meta name="citation_title" content="Shakespeare and Company Project"/>
<meta name="citation_date" content="2020"/>
{% elif page.contentpage or page.essaypage %} {# content/essay page citation details #}
<meta name="citation_title" content="{{ page.title|escape }}"/>
{% for author_block in page.authors %}
<meta name="citation_author" content="{{ author_block.value.lastname_first }}">
{% endfor %}
<meta name="citation_date" content="{{ page.first_published_at|date:"Y/m/d" }}"/>
{% endif %}
{# open graph metadata #}
{% if meta_page_title %}
<meta property="og:title" content="{{ meta_page_title }}" />
{% endif %}
<meta property="og:type" content="website" />
{% if meta_description %}
<meta property="og:description" content="{{ meta_description }}"/>
{% endif %}
<meta property="og:site_name" content="Shakespeare and Company Project"/>
{# twitter card #}
<meta name="twitter:card" content="summary{% if page.contentpage.featured_image or page_iiif_image %}_large_image{% endif %}" />
{% if meta_page_title %}
<meta name="twitter:title" content="{{ meta_page_title }}"/>
{% endif %}
{% if meta_description %}
<meta name="twitter:description" content="{{ meta_description }}" />
{% endif %}
{# <meta name="twitter:site" content="" /> add if/when S&co project has a twitter account#}
{% if request %} {# full urls required for image, dependent on request in context #}
{% with default_image="img/social.png" %}
{% if page.contentpage.featured_image %}
{% image page.contentpage.featured_image max-1080x1080 as featured_image %}
{% elif page.essaypage.featured_image %}
{% image page.essaypage.featured_image max-1080x1080 as featured_image %}
{% elif page.landingpage.header_image %}
{% image page.landingpage.header_image max-1080x1080 as featured_image %}
{% endif %}
{% if featured_image %}
{# using fullurl twice because it doesn't support capturing result #}
<meta property="og:image" content="{% buildfullurl featured_image.url %}" />
<meta name="twitter:image" content="{% buildfullurl featured_image.url %}" />
{% elif page_iiif_image %} {# IIIF image for preview #}
{% with page_iiif_image|iiif_image:"size:width=1080" as image %}
<meta property="og:image" content="{{ image }}" />
<meta name="twitter:image" content="{{ image }}" />
{% endwith %}
{% else %}
<meta property="og:image" content="{% fullstatic default_image %}" />
<meta property="twitter:image" content="{% fullstatic default_image %}" />
{% endif %}
{% endwith %}
<meta property="og:url" content="{{ request.build_absolute_uri }}" />
<meta name="twitter:url" content="{{ request.build_absolute_uri }}" />
<meta name="twitter:domain" content="{{ request.get_host }}" />
<meta name="twitter:site" content="@ShakesCoProject" />
{% for author_block in page.authors %}{% if author_block.value.twitter_id %}
<meta name="twitter:creator" content="{{ author_block.value.twitter_id }}" />
{% endif %}{% endfor %}
{% endif %}