Skip to content

Commit f673967

Browse files
committed
improved seo
1 parent b33a2be commit f673967

File tree

2 files changed

+152
-10
lines changed

2 files changed

+152
-10
lines changed

public/robots.txt

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,46 @@
1+
# Allow all major search engine and AI crawlers
2+
User-agent: Googlebot
3+
Allow: /
4+
5+
User-agent: Bingbot
6+
Allow: /
7+
8+
User-agent: Mediapartners-Google
9+
Allow: /
10+
11+
User-agent: AdsBot-Google # Google AdSense crawler
12+
Allow: /
13+
14+
User-agent: Google-InspectionTool # Google Live Tests/Rich Results Test
15+
Allow: /
16+
17+
User-agent: GPTBot # ChatGPT/OpenAI crawler
18+
Allow: /
19+
20+
User-agent: ClaudeBot
21+
Allow: /
22+
23+
User-agent: CCBot
24+
Allow: /
25+
26+
User-agent: OAI-SearchBot # OpenAI search crawler
27+
Allow: /
28+
29+
User-agent: Bytespider # TikTok crawler
30+
Allow: /
31+
32+
User-agent: facebookexternalhit
33+
Allow: /
34+
35+
User-agent: Twitterbot
36+
Allow: /
37+
38+
User-agent: LinkedInBot
39+
Allow: /
40+
41+
User-agent: WhatsApp
42+
Allow: /
43+
144
User-agent: *
245
Allow: /
346

src/components/bases/head.astro

Lines changed: 109 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -54,9 +54,6 @@ const OGImage = new URL(meta.ogImage, Astro.url).href;
5454
window.dataLayer = window.dataLayer || [];
5555
function gtag(){dataLayer.push(arguments);}
5656

57-
// Debug: Log when gtag is defined
58-
// console.log("Google Analytics script loaded, gtag function defined");
59-
6057
// Set default consent state - advertising and functional are mandatory, others denied until user chooses
6158
gtag('consent', 'default', {
6259
'ad_storage': 'granted', // Always granted for AdSense
@@ -75,9 +72,6 @@ const OGImage = new URL(meta.ogImage, Astro.url).href;
7572
'allow_ad_personalization_signals': false
7673
});
7774

78-
// Debug: Confirm gtag config is set
79-
// console.log("Google Analytics configured with ID:", gaId);
80-
8175
// Make gtag globally available for debugging
8276
window.gtag = gtag;
8377
</script>
@@ -106,14 +100,46 @@ const OGImage = new URL(meta.ogImage, Astro.url).href;
106100
href={new URL("rss.xml", Astro.site)}
107101
/>
108102

103+
<!-- Additional SEO Links -->
104+
<link rel="home" href={new URL("/", Astro.site)} />
105+
<link rel="author" href={new URL("/about", Astro.site)} />
106+
<link rel="help" href={new URL("/contact", Astro.site)} />
107+
<link rel="privacy-policy" href={new URL("/privacy", Astro.site)} />
108+
<link rel="terms-of-service" href={new URL("/terms", Astro.site)} />
109+
110+
<!-- Preconnect to external domains for performance -->
111+
<link rel="preconnect" href="https://fonts.googleapis.com" />
112+
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin />
113+
<link rel="preconnect" href="https://www.google-analytics.com" />
114+
<link rel="preconnect" href="https://www.googletagmanager.com" />
115+
<link rel="preconnect" href="https://pagead2.googlesyndication.com" />
116+
117+
<!-- DNS prefetch for external resources -->
118+
<link rel="dns-prefetch" href="//www.google-analytics.com" />
119+
<link rel="dns-prefetch" href="//www.googletagmanager.com" />
120+
<link rel="dns-prefetch" href="//pagead2.googlesyndication.com" />
121+
109122
<!-- Canonical URL -->
110123
<link rel="canonical" href={meta.canonical || canonicalURL} />
111124

112125
<!-- Page Metadata -->
113126
<title>{isArticleMeta(meta) || Astro.url.pathname.includes('/authors/') ? meta.title : Astro.url.pathname.includes('/categories/') ? `${Astro.url.pathname.split('/')[2].charAt(0).toUpperCase() + Astro.url.pathname.split('/')[2].slice(1)} Articles | ${SITE.title}` : meta.title}</title>
114127
<meta name="title" content={isArticleMeta(meta) || Astro.url.pathname.includes('/authors/') ? meta.metaTitle : Astro.url.pathname.includes('/categories/') ? `${Astro.url.pathname.split('/')[2].charAt(0).toUpperCase() + Astro.url.pathname.split('/')[2].slice(1)} Articles` : meta.metaTitle} />
115128
<meta name="description" content={meta.description} />
116-
{meta.robots ? <meta name="robots" content={meta.robots} /> : null}
129+
<meta name="robots" content="index, follow" />
130+
<meta name="author" content={SITE.author} />
131+
<meta name="language" content="en-US" />
132+
<meta name="revisit-after" content="7 days" />
133+
<meta name="distribution" content="global" />
134+
<meta name="rating" content="general" />
135+
<meta http-equiv="content-language" content="en-US" />
136+
<meta http-equiv="content-type" content="text/html; charset=UTF-8" />
137+
<meta name="theme-color" content="#ffffff" />
138+
<meta name="msapplication-TileColor" content="#ffffff" />
139+
<meta name="apple-mobile-web-app-capable" content="yes" />
140+
<meta name="apple-mobile-web-app-status-bar-style" content="default" />
141+
<meta name="format-detection" content="telephone=no" />
142+
<meta name="referrer" content="strict-origin-when-cross-origin" />
117143
{
118144
meta.xRobotsTag ? (
119145
<meta http-equiv="X-Robots-Tag" content={meta.xRobotsTag} />
@@ -138,15 +164,29 @@ const OGImage = new URL(meta.ogImage, Astro.url).href;
138164
<meta property="og:description" content={meta.description} />
139165
<meta property="og:image" content={OGImage} />
140166
<meta property="og:image:alt" content={meta.ogImageAlt} />
167+
<meta property="og:site_name" content={SITE.title} />
168+
<meta property="og:locale" content="en_US" />
169+
{
170+
isArticleMeta(meta) && meta.keywords && meta.keywords.length > 0 ? (
171+
meta.keywords.slice(0, 5).map((keyword) => (
172+
<meta property="article:tag" content={keyword} />
173+
))
174+
) : null
175+
}
141176

142177
<!-- Twitter -->
143-
<meta property="twitter:site" content={Astro.site} />
144178
<meta property="twitter:card" content="summary_large_image" />
145179
<meta property="twitter:url" content={canonicalURL} />
146180
<meta property="twitter:title" content={isArticleMeta(meta) || Astro.url.pathname.includes('/authors/') ? meta.title : Astro.url.pathname.includes('/categories/') ? `${Astro.url.pathname.split('/')[2].charAt(0).toUpperCase() + Astro.url.pathname.split('/')[2].slice(1)} Articles | ${SITE.title}` : meta.title} />
147181
<meta property="twitter:description" content={meta.description} />
148182
<meta property="twitter:image" content={OGImage} />
149183
<meta property="twitter:image:alt" content={meta.ogImageAlt} />
184+
<meta property="twitter:site" content="@dailynest" />
185+
{
186+
isArticleMeta(meta) && meta.authors && meta.authors.length > 0 ? (
187+
<meta property="twitter:creator" content={`@${meta.authors[0].name.toLowerCase().replace(/\s+/g, '')}`} />
188+
) : null
189+
}
150190

151191
{
152192
isArticleMeta(meta) ? (
@@ -167,7 +207,7 @@ const OGImage = new URL(meta.ogImage, Astro.url).href;
167207
<meta property="author" content={author.name} />
168208
<meta
169209
property="article:author"
170-
content={`${Astro.site}authors/${author.link}`}
210+
content={new URL(`authors/${author.link}`, Astro.site).href}
171211
/>
172212
</>
173213
))}
@@ -182,7 +222,7 @@ const OGImage = new URL(meta.ogImage, Astro.url).href;
182222
image: [OGImage],
183223
datePublished: new Date(meta.publishedTime).toISOString(),
184224
...(meta.lastModified && { dateModified: new Date(meta.lastModified).toISOString() }),
185-
author: meta.authors.map((a) => ({ '@type': 'Person', name: a.name, url: `${Astro.site}authors/${a.link}` })),
225+
author: meta.authors.map((a) => ({ '@type': 'Person', name: a.name, url: new URL(`authors/${a.link}`, Astro.site).href })),
186226
mainEntityOfPage: {
187227
'@type': 'WebPage',
188228
'@id': meta.canonical || canonicalURL,
@@ -195,6 +235,43 @@ const OGImage = new URL(meta.ogImage, Astro.url).href;
195235
url: new URL('/favicon.png', Astro.site).href,
196236
},
197237
},
238+
...(meta.keywords && meta.keywords.length > 0 && { keywords: meta.keywords.join(', ') }),
239+
...(meta.wordCount && { wordCount: meta.wordCount }),
240+
articleSection: meta.category || 'Blog',
241+
inLanguage: 'en-US',
242+
isAccessibleForFree: true,
243+
copyrightHolder: {
244+
'@type': 'Organization',
245+
name: SITE.title,
246+
},
247+
})}
248+
</script>
249+
250+
<!-- Breadcrumb structured data -->
251+
<script type="application/ld+json">
252+
{JSON.stringify({
253+
'@context': 'https://schema.org',
254+
'@type': 'BreadcrumbList',
255+
itemListElement: [
256+
{
257+
'@type': 'ListItem',
258+
position: 1,
259+
name: 'Home',
260+
item: new URL('/', Astro.site).href,
261+
},
262+
{
263+
'@type': 'ListItem',
264+
position: 2,
265+
name: meta.category || 'Blog',
266+
item: new URL(`/categories/${meta.category?.toLowerCase() || 'blog'}`, Astro.site).href,
267+
},
268+
{
269+
'@type': 'ListItem',
270+
position: 3,
271+
name: meta.title,
272+
item: meta.canonical || canonicalURL,
273+
},
274+
],
198275
})}
199276
</script>
200277
</>
@@ -209,6 +286,28 @@ const OGImage = new URL(meta.ogImage, Astro.url).href;
209286
'@type': 'WebSite',
210287
name: meta.metaTitle,
211288
url: SITE.url,
289+
description: meta.description,
290+
publisher: {
291+
'@type': 'Organization',
292+
name: SITE.title,
293+
logo: {
294+
'@type': 'ImageObject',
295+
url: new URL('/favicon.png', Astro.site).href,
296+
},
297+
},
298+
potentialAction: {
299+
'@type': 'SearchAction',
300+
target: {
301+
'@type': 'EntryPoint',
302+
urlTemplate: new URL('/search?q={search_term_string}', Astro.site).href,
303+
},
304+
'query-input': 'required name=search_term_string',
305+
},
306+
inLanguage: 'en-US',
307+
copyrightHolder: {
308+
'@type': 'Organization',
309+
name: SITE.title,
310+
},
212311
})}
213312
</script>
214313
) : null

0 commit comments

Comments
 (0)