fix: HTTPS URLs in sitemap, robots, canonical + og:image on homepage
- Add UseForwardedHeaders middleware so Request.Scheme = "https" behind nginx - Add SITE_BASE_URL env var fallback for sitemap.xml, robots.txt, and all Razor page canonical/og URLs — set it to https://draletaha.ir in .env - Add og:image to homepage using hero photo - Add SITE_BASE_URL to docker-compose.yml environment block Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
@page
|
||||
@model IndexModel
|
||||
@{
|
||||
var siteBaseUrl = Environment.GetEnvironmentVariable("SITE_BASE_URL")?.TrimEnd('/') ?? (siteBaseUrl);
|
||||
var h = Model.Hero;
|
||||
var a = Model.About;
|
||||
var c = Model.Contact;
|
||||
@@ -24,14 +25,21 @@
|
||||
<meta property="og:title" content="@ViewData["Title"]" />
|
||||
<meta property="og:description" content="@h.GetValueOrDefault("subtitle","")" />
|
||||
<meta property="og:locale" content="fa_IR" />
|
||||
<link rel="canonical" href="@(Request.Scheme + "://" + Request.Host + "/")" />
|
||||
@if (!string.IsNullOrEmpty(heroImg))
|
||||
{
|
||||
var absHeroImg = heroImg.StartsWith("http") ? heroImg : (siteBaseUrl + heroImg);
|
||||
<meta property="og:image" content="@absHeroImg" />
|
||||
<meta property="og:image:width" content="1200" />
|
||||
<meta property="og:image:height" content="630" />
|
||||
}
|
||||
<link rel="canonical" href="@(siteBaseUrl + "/")" />
|
||||
<script type="application/ld+json">
|
||||
{
|
||||
"@@context":"https://schema.org",
|
||||
"@@type":["MedicalBusiness","LocalBusiness"],
|
||||
"name":"@siteName",
|
||||
"description":"@h.GetValueOrDefault("subtitle","")",
|
||||
"url":"@(Request.Scheme + "://" + Request.Host)",
|
||||
"url":"@(siteBaseUrl)",
|
||||
"telephone":"@c.GetValueOrDefault("phone","")",
|
||||
"address":{"@@type":"PostalAddress","addressLocality":"تهران","addressCountry":"IR","streetAddress":"@c.GetValueOrDefault("address","")"},
|
||||
"openingHours":"@c.GetValueOrDefault("hours","")",
|
||||
|
||||
Reference in New Issue
Block a user