Skip to content

Commit 403013c

Browse files
author
TechStack Global
committed
SEO: Rank #1 Optimization Sprint - Canonical repair, Twitter metadata, and branding sync
1 parent 618d9e9 commit 403013c

File tree

2 files changed

+74
-1
lines changed

2 files changed

+74
-1
lines changed

posts/xreal-1s-vs-meta-quest-3.html

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,9 @@
2222
<meta property="og:image" content="https://techstackglobal.github.io/posts/images/xreal-1s-vs-meta-3-xreal.jpg">
2323

2424
<!-- Twitter -->
25+
<meta name="twitter:image" content="https://techstackglobal.github.io/posts/images/xreal-1s-vs-meta-3-xreal.jpg">
26+
<meta name="twitter:description" content="Choosing between the VR powerhouse and the AR lightweight. Our deep dive into which device actually replaces your monitors.">
27+
<meta name="twitter:title" content="XREAL 1S vs. Meta Quest 3: Bulk vs. Blueprint (2026 Comparison)">
2528
<meta name="twitter:card" content="summary_large_image">
2629

2730
<link href="https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800&display=swap" rel="stylesheet">
@@ -139,12 +142,13 @@
139142
"name": "TechStack Global",
140143
"logo": {
141144
"@type": "ImageObject",
142-
"url": "https://techstackglobal.github.io/assets/icons/techstack-logo-192.png"
145+
"url": "https://techstackglobal.github.io/apple-touch-icon.png"
143146
}
144147
},
145148
"description": "Comparison of XREAL 1S AR glasses and Meta Quest 3 VR headset for daily work and gaming."
146149
}
147150
</script>
151+
<link rel="canonical" href="https://techstackglobal.github.io/posts/xreal-1s-vs-meta-quest-3.html" />
148152
</head>
149153
<body class="dark-theme">
150154
<div class="ambient-grid"></div>

rank_one_optimize.py

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
import os
2+
import re
3+
4+
BASE_DIR = r'c:\Users\PMLS\Desktop\Youtube Shorts\b2b_blog'
5+
POSTS_DIR = os.path.join(BASE_DIR, 'posts')
6+
7+
def get_meta_content(content, property_name):
8+
match = re.search(f'<meta property="{property_name}" content="([^"]+)"', content)
9+
if not match:
10+
match = re.search(f'<meta name="{property_name}" content="([^"]+)"', content)
11+
return match.group(1) if match else None
12+
13+
def optimize_file(fpath):
14+
with open(fpath, 'r', encoding='utf-8') as f:
15+
content = f.read()
16+
17+
new_content = content
18+
rel_path = os.path.relpath(fpath, BASE_DIR).replace('\\', '/')
19+
canonical_url = f"https://techstackglobal.github.io/{rel_path}"
20+
21+
# 1. Ensure Canonical Tag exists
22+
if '<link rel="canonical"' not in new_content and '<link href="https://techstackglobal.github.io' not in new_content:
23+
# Insert before </head>
24+
new_content = new_content.replace('</head>', f' <link rel="canonical" href="{canonical_url}" />\n</head>')
25+
print(f"Added Canonical: {rel_path}")
26+
27+
# 2. Inject/Update Twitter Metadata based on OpenGraph
28+
og_title = get_meta_content(new_content, "og:title")
29+
og_desc = get_meta_content(new_content, "og:description")
30+
og_image = get_meta_content(new_content, "og:image")
31+
32+
if og_title and 'name="twitter:title"' not in new_content:
33+
new_content = new_content.replace('<!-- Twitter -->', f'<!-- Twitter -->\n <meta name="twitter:title" content="{og_title}">')
34+
if og_desc and 'name="twitter:description"' not in new_content:
35+
new_content = new_content.replace('<!-- Twitter -->', f'<!-- Twitter -->\n <meta name="twitter:description" content="{og_desc}">')
36+
if og_image and 'name="twitter:image"' not in new_content:
37+
new_content = new_content.replace('<!-- Twitter -->', f'<!-- Twitter -->\n <meta name="twitter:image" content="{og_image}">')
38+
if 'name="twitter:card"' not in new_content:
39+
new_content = new_content.replace('<!-- Twitter -->', '<!-- Twitter -->\n <meta name="twitter:card" content="summary_large_image">')
40+
41+
# 3. Synchronize Schema Logo
42+
# Old: /assets/icons/techstack-logo-192.png
43+
# New: /apple-touch-icon.png (high res TSG)
44+
old_logo_path = "assets/icons/techstack-logo-192.png"
45+
new_logo_url = "https://techstackglobal.github.io/apple-touch-icon.png"
46+
if old_logo_path in new_content:
47+
new_content = new_content.replace(old_logo_path, "apple-touch-icon.png")
48+
print(f"Updated Schema Logo: {rel_path}")
49+
50+
if new_content != content:
51+
with open(fpath, 'w', encoding='utf-8') as f:
52+
f.write(new_content)
53+
return True
54+
return False
55+
56+
# Execution logic
57+
files_to_check = []
58+
for root, dirs, files in os.walk(BASE_DIR):
59+
if any(skip in root for skip in ['.git', '.agent', 'node_modules', '.venv']): continue
60+
for f in files:
61+
if f.endswith('.html'):
62+
files_to_check.append(os.path.join(root, f))
63+
64+
updated = 0
65+
for fpath in files_to_check:
66+
if optimize_file(fpath):
67+
updated += 1
68+
69+
print(f"\nOptimization Sweep Complete. Files Prepared: {updated}")

0 commit comments

Comments
 (0)