Skip to content

Instantly share code, notes, and snippets.

@treetop1500
Last active December 22, 2023 08:12
Show Gist options
  • Star 4 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save treetop1500/c198368e95dda6e60ac1ebf975fffe47 to your computer and use it in GitHub Desktop.
Save treetop1500/c198368e95dda6e60ac1ebf975fffe47 to your computer and use it in GitHub Desktop.
Twig template for meta tags, titles and other head element meta data.
{#
Relies mostly on a meta array containing appropriate values.
site_name is a parameter set as a Twig Global
default_share_image is a fallback parameter set as a Twig Global
#}
<meta charset="UTF-8">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="robots" content="index, follow" />
<meta property="og:type" content="website" />
<meta property="og:url" content="{{ app.request.uri }}" />
<meta property="og:site_name" content="{{ site_name }}" />
<meta name="twitter:site" content="@(twitterusername)" />
<meta name="twitter:creator" content="@grayloon" />
<meta property="og:locale" content="en_US" />
<meta name="twitter:card" content="summary" />
<meta name="geo.region" content="US-IN" />
<meta name="geo.placename" content="Evansville" />
<meta name="geo.position" content="XX;-XX" />
<meta name="ICBM" content="XX, -XX" />
{# @todo determine if canonical link tag necessary for this site
<link rel="canonical" href="" />
#}
{# @todo if site verification tags must be implemented
<meta name="google-site-verification" content="">
meta name="msvalidate.01" content="">
#}
{%- if meta.metaTitle is defined and meta.metaTitle is not empty %}
<meta property="title" content="{{ meta.metaTitle }}" />
{% endif -%}
{%- if meta.metaDescription is defined and meta.metaDescription is not empty %}
<meta property="description" content="{{ meta.metaDescription }}" />
{% endif -%}
{%- if meta.ogTitle is defined and meta.ogTitle is not empty %}
<meta property="og:title" content="{{ meta.ogTitle }}" />
<meta name="twitter:title" content="{{ meta.ogTitle }}" />
{% endif -%}
{%- if meta.ogDescription is defined and meta.ogDescription is not empty %}
<meta property="og:description" content="{{ meta.ogDescription }}" />
<meta name="twitter:description" content="{{ meta.ogDescription }}" />
{% endif -%}
{%- if meta.ogImage is defined and meta.ogImage is not empty %}
<meta property="og:image" content="{{ app.request.getUriForPath(vich_uploader_asset(meta.ogImage, "uploadFile")) }}" />
<meta name="twitter:image" content="{{ app.request.getUriForPath(vich_uploader_asset(meta.ogImage, "uploadFile")) }}" />
{% else %}
<meta property="og:image" content="{{ app.request.getUriForPath(asset(default_share_image)) }}" />
<meta name="twitter:image" content="{{ app.request.getUriForPath(asset(default_share_image)) }}" />
{% endif -%}
<title>
{% block title %}
{{ meta.pageTitle is defined and meta.pageTitle is not empty ? meta.pageTitle~" - " }}{{ site_name }}
{% endblock %}
</title>
@Minthyzzz
Copy link

poop

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment