Skip to content

Commit b0fc960

Browse files
committed
SEO, AdSense, Analytics 종합 개선
- og:image, twitter:image 메타 태그 추가 (SNS 공유 이미지) - favicon, apple-touch-icon, theme-color 태그 추가 - RSS discovery 링크 태그 추가 - JSON-LD: image, dateModified, BreadcrumbList, author url/sameAs 추가 - 페이지네이션 /page2+ noindex 처리 - AdSense 스크립트 전체 페이지 확대 (홈/카테고리 수익화) - 광고 CLS 개선 (min-height 250px) + 빈 광고 8초 후 collapse - 하단 광고 lazy loading (IntersectionObserver) - 관련 포스트 섹션 추가 (동일 카테고리 5개) - Mermaid.js 조건부 로딩 (DOM 감지) - GA4 스크롤 깊이 + 외부 링크 클릭 추적 - sitemap 이미지 확장, feed.xml description 개선 - preconnect 보강, CSS preload 추가 - 레거시 UA ID 제거
1 parent 9ce90c8 commit b0fc960

8 files changed

Lines changed: 189 additions & 41 deletions

File tree

_config.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ title: MadPlay🚀
33
description: "Curiosity and Experience never get old."
44
url: "https://madplay.github.io"
55
baseurl: ""
6-
g-analytics: "UA-111002457-1"
76
ga4_measurement_id: "G-YH3W70BTL1"
87

98
# Language Settings

_layouts/default.html

Lines changed: 55 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,15 @@
99

1010
<meta name="description"
1111
content="{% if page.excerpt %}{{ page.excerpt | strip_html | strip_newlines | truncate: 160 }}{% else %}{{ site.description }}{% endif %}">
12+
{% if paginator and paginator.page > 1 %}
13+
<meta name="robots" content="noindex, follow">
14+
{% endif %}
1215
<meta name="author" content="{{ site.title }}">
1316
<meta name="naver-site-verification" content="20a36484bff01ff10cf2e8ba576bd3a6724dabd6" />
17+
<link rel="icon" type="image/x-icon" href="{{ site.baseurl }}/favicon.ico">
18+
<link rel="apple-touch-icon" href="{{ site.baseurl }}/img/common/og_image.png">
19+
<meta name="theme-color" content="#09090b">
20+
<link rel="alternate" type="application/rss+xml" title="{{ site.title }}" href="{{ site.url }}{{ site.baseurl }}/feed.xml">
1421

1522
{% assign current_lang = page.lang | default: site.default_lang %}
1623
{% if page.url %}
@@ -38,11 +45,14 @@
3845
{% if page.author %}
3946
"author": {
4047
"@type": "Person",
41-
"name": {{page.author | jsonify}}
48+
"name": {{page.author | jsonify}},
49+
"url": "{{ site.url }}{{ site.baseurl }}/about",
50+
"sameAs": ["https://github.com/{{ page.author }}"]
4251
},
4352
{% endif %}
53+
"image": "{{ site.url }}{{ site.baseurl }}{% if page.image %}{{ page.image }}{% else %}/img/common/og_image.png{% endif %}",
4454
"datePublished": "{{ page.date | date_to_xmlschema }}",
45-
"dateModified": "{{ page.date | date_to_xmlschema }}",
55+
"dateModified": "{{ page.last_modified_at | default: page.date | date_to_xmlschema }}",
4656
"mainEntityOfPage": {
4757
"@type": "WebPage",
4858
"@id": "{{ site.url }}{{ site.baseurl }}{{ page.url | replace:'index.html','' }}"
@@ -65,6 +75,36 @@
6575
"url": "{{ site.url }}{{ site.baseurl }}{{ page.url | replace:'index.html','' }}"
6676
}
6777
</script>
78+
<script type="application/ld+json">
79+
{
80+
"@context": "https://schema.org",
81+
"@type": "BreadcrumbList",
82+
"itemListElement": [
83+
{
84+
"@type": "ListItem",
85+
"position": 1,
86+
"name": "MadPlay",
87+
"item": "{{ site.url }}{{ site.baseurl }}/"
88+
}{% if page.category %},
89+
{
90+
"@type": "ListItem",
91+
"position": 2,
92+
"name": {{ page.category | jsonify }},
93+
"item": "{{ site.url }}{{ site.baseurl }}/category"
94+
},
95+
{
96+
"@type": "ListItem",
97+
"position": 3,
98+
"name": {{ page.title | jsonify }}
99+
}{% else %},
100+
{
101+
"@type": "ListItem",
102+
"position": 2,
103+
"name": {{ page.title | jsonify }}
104+
}{% endif %}
105+
]
106+
}
107+
</script>
68108
{% endif %}
69109
{% endif %}
70110

@@ -75,11 +115,21 @@
75115
{% if page.url %}
76116
<meta property="og:url" content="{{ site.url }}{{ site.baseurl }}{{ page.url | replace:'index.html','' }}">
77117
{% endif %}
118+
{% if page.image %}
119+
<meta property="og:image" content="{{ site.url }}{{ site.baseurl }}{{ page.image }}">
120+
{% else %}
121+
<meta property="og:image" content="{{ site.url }}{{ site.baseurl }}/img/common/og_image.png">
122+
{% endif %}
78123

79124
<meta name="twitter:card" content="summary">
80125
<meta name="twitter:title" content="{% if page.title %}{{ page.title }}{% else %}{{ site.title }}{% endif %}">
81126
<meta name="twitter:description"
82127
content="{% if page.excerpt %}{{ page.excerpt | strip_html | strip_newlines | truncate: 160 }}{% else %}{{ site.description }}{% endif %}">
128+
{% if page.image %}
129+
<meta name="twitter:image" content="{{ site.url }}{{ site.baseurl }}{{ page.image }}">
130+
{% else %}
131+
<meta name="twitter:image" content="{{ site.url }}{{ site.baseurl }}/img/common/og_image.png">
132+
{% endif %}
83133
<style>
84134
html {
85135
background-color: rgb(9 9 11);
@@ -99,8 +149,8 @@
99149
<link rel="preconnect" href="https://www.googletagmanager.com">
100150
{% endif %}
101151

152+
<link rel="preconnect" href="https://pagead2.googlesyndication.com" crossorigin>
102153
{% if page.layout == 'post' %}
103-
<link rel="dns-prefetch" href="//pagead2.googlesyndication.com">
104154
<link rel="dns-prefetch" href="//utteranc.es">
105155
{% endif %}
106156

@@ -114,12 +164,12 @@
114164
</script>
115165
{% endif %}
116166

117-
{% if page.layout == 'post' %}
118167
<script async
119168
src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js?client=ca-pub-8036596086585080"
120169
crossorigin="anonymous"></script>
121-
{% endif %}
122170

171+
<link rel="preload" href="{{ site.baseurl }}/css/custom/utilities.css" as="style">
172+
<link rel="preload" href="{{ site.baseurl }}/css/custom/default.css" as="style">
123173
<link rel="stylesheet" href="{{ site.baseurl }}/css/custom/utilities.css">
124174
<link rel="stylesheet" href="{{ site.baseurl }}/css/custom/default.css">
125175
{% if page.layout == 'post' %}

_layouts/post.html

Lines changed: 35 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,6 @@ <h1 class="text-3xl md:text-5xl font-medium text-zinc-100 leading-tight mb-6 md:
8787
data-ad-format="fluid"
8888
data-ad-client="ca-pub-8036596086585080"
8989
data-ad-slot="7241821159"></ins>
90-
<script>(adsbygoogle = window.adsbygoogle || []).push({});</script>
9190
</div>
9291

9392
{% assign current_lang = page.lang | default: site.default_lang %}
@@ -173,6 +172,32 @@ <h1 class="text-3xl md:text-5xl font-medium text-zinc-100 leading-tight mb-6 md:
173172
data-label="comment"
174173
data-theme="github-dark"></div>
175174
</div>
175+
176+
{% assign current_lang = page.lang | default: site.default_lang %}
177+
{% assign related_posts = "" | split: "" %}
178+
{% assign related_count = 0 %}
179+
{% for p in site.posts %}
180+
{% if related_count >= 5 %}{% break %}{% endif %}
181+
{% if p.category == page.category and p.url != page.url %}
182+
{% assign p_lang = p.lang | default: site.default_lang %}
183+
{% if p_lang == current_lang %}
184+
{% assign related_posts = related_posts | push: p %}
185+
{% assign related_count = related_count | plus: 1 %}
186+
{% endif %}
187+
{% endif %}
188+
{% endfor %}
189+
{% if related_posts.size > 0 %}
190+
<section class="related-posts mt-16 pt-8 border-t border-zinc-900">
191+
<h3 class="text-lg font-medium text-zinc-300 mb-6">{% if current_lang == 'en' %}Related Posts{% else %}관련 포스트{% endif %}</h3>
192+
<div class="space-y-3">
193+
{% for rpost in related_posts %}
194+
<a href="{{ site.baseurl }}{{ rpost.url }}" class="block py-3 px-4 bg-zinc-900 hover:bg-zinc-800 border border-zinc-800 hover:border-zinc-700 rounded-lg text-zinc-300 hover:text-zinc-100 transition-all duration-200 text-sm">
195+
{{ rpost.title }}
196+
</a>
197+
{% endfor %}
198+
</div>
199+
</section>
200+
{% endif %}
176201
</div>
177202

178203
<aside class="post-toc" aria-label="{% if current_lang == 'en' %}Table of contents{% else %}목차{% endif %}">
@@ -184,5 +209,12 @@ <h1 class="text-3xl md:text-5xl font-medium text-zinc-100 leading-tight mb-6 md:
184209
</div>
185210
</article>
186211

187-
<script src="https://cdn.jsdelivr.net/npm/mermaid@11/dist/mermaid.min.js"></script>
188-
<script>mermaid.initialize({theme: 'dark', flowchart: {rankSpacing: 30}});</script>
212+
<script>
213+
(function() {
214+
if (!document.querySelector('.language-mermaid, .mermaid, pre.mermaid')) return;
215+
var s = document.createElement('script');
216+
s.src = 'https://cdn.jsdelivr.net/npm/mermaid@11/dist/mermaid.min.js';
217+
s.onload = function() { mermaid.initialize({theme: 'dark', flowchart: {rankSpacing: 30}}); };
218+
document.body.appendChild(s);
219+
})();
220+
</script>

category.html

Lines changed: 27 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -75,34 +75,6 @@ <h2 class="category-section-title">
7575
</div>
7676

7777
<script>
78-
function shuffleCategoryGroups() {
79-
const tagsContainer = document.querySelector('.category-tags');
80-
const sectionsContainer = document.querySelector('.category-sections');
81-
if (!tagsContainer || !sectionsContainer) return;
82-
83-
const tags = Array.from(tagsContainer.querySelectorAll('.category-tag[href^="#"]'));
84-
const sections = Array.from(sectionsContainer.querySelectorAll('.category-section[id]'));
85-
if (tags.length === 0 || sections.length === 0) return;
86-
87-
const groups = tags.map(tag => {
88-
const href = tag.getAttribute('href');
89-
const section = href ? sectionsContainer.querySelector(href) : null;
90-
return section ? { tag, section } : null;
91-
}).filter(Boolean);
92-
93-
for (let i = groups.length - 1; i > 0; i--) {
94-
const j = Math.floor(Math.random() * (i + 1));
95-
[groups[i], groups[j]] = [groups[j], groups[i]];
96-
}
97-
98-
groups.forEach(group => {
99-
tagsContainer.appendChild(group.tag);
100-
sectionsContainer.appendChild(group.section);
101-
});
102-
}
103-
104-
shuffleCategoryGroups();
105-
10678
document.querySelectorAll('.category-tag[href^="#"]').forEach(anchor => {
10779
anchor.addEventListener('click', function (e) {
10880
e.preventDefault();
@@ -164,4 +136,31 @@ <h2 class="category-section-title">
164136
});
165137

166138
updateActiveTag();
139+
140+
function shuffleCategoryGroups() {
141+
var container = document.querySelector('.category-sections');
142+
var tagContainer = document.querySelector('.category-tags');
143+
if (!container || !tagContainer) return;
144+
145+
var sections = Array.from(container.querySelectorAll('.category-section'));
146+
var tags = Array.from(tagContainer.querySelectorAll('.category-tag'));
147+
148+
var pairs = sections.map(function(section, i) {
149+
return { section: section, tag: tags[i] };
150+
});
151+
152+
for (var i = pairs.length - 1; i > 0; i--) {
153+
var j = Math.floor(Math.random() * (i + 1));
154+
var temp = pairs[i];
155+
pairs[i] = pairs[j];
156+
pairs[j] = temp;
157+
}
158+
159+
pairs.forEach(function(pair) {
160+
container.appendChild(pair.section);
161+
tagContainer.appendChild(pair.tag);
162+
});
163+
}
164+
165+
shuffleCategoryGroups();
167166
</script>

css/custom/post.css

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -742,7 +742,7 @@
742742
max-width: 50rem;
743743
text-align: center;
744744
padding: 0.5rem 0;
745-
min-height: 100px;
745+
min-height: 250px;
746746
}
747747

748748
.ad-container-top {
@@ -759,7 +759,7 @@
759759

760760
@media (max-width: 768px) {
761761
.ad-container {
762-
min-height: 80px;
762+
min-height: 200px;
763763
margin: 1.5rem auto;
764764
}
765765

feed.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ layout: null
1414
{% for post in site.posts limit:30 %}
1515
<item>
1616
<title>{{ post.title | xml_escape }}</title>
17-
<description>{{ post.content | strip_html | xml_escape }}</description>
17+
<description>{{ post.description | default: post.excerpt | strip_html | truncate: 300 | xml_escape }}</description>
1818
<pubDate>{{ post.date | date_to_rfc822 }}</pubDate>
1919
<link>{{ post.url | prepend: site.baseurl | prepend: site.url }}</link>
2020
<guid isPermaLink="true">{{ post.url | prepend: site.baseurl | prepend: site.url }}</guid>

js/post-performance.js

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,10 +152,73 @@
152152
runWhenIdle(loadCopyScript, 2600);
153153
}
154154

155+
function collapseEmptyAds() {
156+
setTimeout(function() {
157+
document.querySelectorAll('.ad-container').forEach(function(el) {
158+
if (!el.querySelector('iframe')) el.style.minHeight = '0';
159+
});
160+
}, 8000);
161+
}
162+
163+
function initLazyBottomAd() {
164+
var bottomAd = document.querySelector('.ad-container-bottom ins.adsbygoogle');
165+
if (!bottomAd || bottomAd.dataset.adsbygoogleStatus) return;
166+
167+
if (!('IntersectionObserver' in window)) {
168+
(adsbygoogle = window.adsbygoogle || []).push({});
169+
return;
170+
}
171+
172+
var observer = new IntersectionObserver(function(entries) {
173+
if (entries[0].isIntersecting) {
174+
observer.disconnect();
175+
(adsbygoogle = window.adsbygoogle || []).push({});
176+
}
177+
}, { rootMargin: '600px 0px' });
178+
observer.observe(bottomAd);
179+
}
180+
181+
function initScrollTracking() {
182+
if (typeof gtag !== 'function') return;
183+
var thresholds = [25, 50, 75, 100];
184+
var fired = {};
185+
window.addEventListener('scroll', function() {
186+
var scrollPct = Math.round(
187+
(window.scrollY + window.innerHeight) / document.body.scrollHeight * 100
188+
);
189+
thresholds.forEach(function(t) {
190+
if (scrollPct >= t && !fired[t]) {
191+
fired[t] = true;
192+
gtag('event', 'scroll_depth', { percent: t });
193+
}
194+
});
195+
}, { passive: true });
196+
}
197+
198+
function initOutboundTracking() {
199+
if (typeof gtag !== 'function') return;
200+
document.addEventListener('click', function(e) {
201+
var link = e.target.closest('a[href]');
202+
if (!link) return;
203+
var href = link.getAttribute('href');
204+
if (href && href.startsWith('http') && href.indexOf('madplay.github.io') === -1) {
205+
if (navigator.sendBeacon) {
206+
gtag('event', 'outbound_click', { url: href, transport_type: 'beacon' });
207+
} else {
208+
gtag('event', 'outbound_click', { url: href });
209+
}
210+
}
211+
});
212+
}
213+
155214
whenReady(function () {
156215
optimizePostImages();
157216
initLazyComments();
158217
initLazyToc();
159218
initLazyCopyButtons();
219+
collapseEmptyAds();
220+
initLazyBottomAd();
221+
initScrollTracking();
222+
initOutboundTracking();
160223
});
161224
})();

sitemap.xml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
layout: null
33
---
44
<?xml version="1.0" encoding="UTF-8"?>
5-
<urlset xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.sitemaps.org/schemas/sitemap/0.9 http://www.sitemaps.org/schemas/sitemap/0.9/sitemap.xsd" xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
5+
<urlset xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.sitemaps.org/schemas/sitemap/0.9 http://www.sitemaps.org/schemas/sitemap/0.9/sitemap.xsd" xmlns="http://www.sitemaps.org/schemas/sitemap/0.9" xmlns:image="http://www.google.com/schemas/sitemap-image/1.1">
66
{% assign latest_post = site.posts | first %}
77
{% assign collections = site.collections | where_exp:'collection','collection.output != false' | sort: 'label' %}
88
{% for collection in collections %}
@@ -13,6 +13,11 @@ layout: null
1313
{% if doc.last_modified_at or doc.date %}
1414
<lastmod>{{ doc.last_modified_at | default: doc.date | date_to_xmlschema }}</lastmod>
1515
{% endif %}
16+
{% if doc.image %}
17+
<image:image>
18+
<image:loc>{{ doc.image | prepend: site.baseurl | prepend: site.url }}</image:loc>
19+
</image:image>
20+
{% endif %}
1621
</url>
1722
{% endfor %}
1823
{% endfor %}

0 commit comments

Comments
 (0)