<% 
  /* Expects: pageTitleFull, metaDescription, canonicalUrl, publicBaseUrl, site, ogType (optional), ogImagePath (optional relative) */
  const _title = typeof pageTitleFull !== "undefined" && pageTitleFull ? pageTitleFull : ((site.businessName || "Site") + " | " + (site.primaryService || "Services"));
  const _desc = typeof metaDescription !== "undefined" && metaDescription ? String(metaDescription) : String(site.primaryService || "") + " — " + String(site.businessName || "");
  const _canon = typeof canonicalUrl !== "undefined" && canonicalUrl ? canonicalUrl : (publicBaseUrl + "/");
  const _base = typeof publicBaseUrl !== "undefined" ? publicBaseUrl : "";
  const _ogType = typeof ogType !== "undefined" && ogType ? ogType : "website";
  const _img = (typeof img !== "undefined" && img) ? img : {};
  const _defaultOg = _img.homeHero || _img.logo || "/images/Logo.jpeg";
  const _defaultIcon = _img.logo || _img.favicon || "/images/Logo.jpeg";
  const _ogPath = typeof ogImagePath !== "undefined" && ogImagePath ? String(ogImagePath) : _defaultOg;
  const _ogAbs = _ogPath.startsWith("http") ? _ogPath : (_base.replace(/\/+$/, "") + (_ogPath.startsWith("/") ? _ogPath : "/" + _ogPath));
  const _lb = typeof localBusinessLd !== "undefined" ? localBusinessLd : null;
  const _wp = typeof webPageLd !== "undefined" ? webPageLd : null;
  const _ws = {
    "@context": "https://schema.org",
    "@type": "WebSite",
    name: site.businessName || "",
    url: _base.replace(/\/+$/, "") + "/",
  };
%>
<link rel="icon" href="<%= _defaultIcon %>" type="image/jpeg" />
<link rel="apple-touch-icon" href="<%= _defaultIcon %>" />
<title><%= _title %></title>
<meta name="description" content="<%= _desc %>" />
<meta name="robots" content="index, follow" />
<link rel="canonical" href="<%= _canon %>" />
<meta property="og:type" content="<%= _ogType %>" />
<meta property="og:title" content="<%= _title %>" />
<meta property="og:description" content="<%= _desc %>" />
<meta property="og:url" content="<%= _canon %>" />
<meta property="og:image" content="<%= _ogAbs %>" />
<meta property="og:site_name" content="<%= site.businessName || "" %>" />
<meta name="twitter:card" content="summary_large_image" />
<meta name="twitter:title" content="<%= _title %>" />
<meta name="twitter:description" content="<%= _desc %>" />
<meta name="twitter:image" content="<%= _ogAbs %>" />
<% if (_lb) { %>
<script type="application/ld+json"><%- JSON.stringify(_lb) %></script>
<% } %>
<script type="application/ld+json"><%- JSON.stringify(_ws) %></script>
<% if (_wp) { %>
<script type="application/ld+json"><%- JSON.stringify(_wp) %></script>
<% } %>
