Skip to content

Commit 5b31e24

Browse files
구글 애드센스 설정 추가
- _config.yml 파일에 구글 애드센스 클라이언트 정보 및 자동 광고 설정 추가 - default.html 레이아웃에 구글 애드센스 포함 태그 추가 - post.html 레이아웃에 포스트 상단 및 하단 광고 포함 - main.css 파일에 애드센스 스타일 추가
1 parent b3c9fe8 commit 5b31e24

6 files changed

Lines changed: 69 additions & 0 deletions

File tree

_config.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,12 @@ default_lang: "ko"
1313
# Google Analytics
1414
google_analytics: G-E2F9P3J8TQ # 실제 GA4 측정 ID로 교체 필요
1515

16+
# Google AdSense
17+
adsense:
18+
client: ca-pub-4992764083187170
19+
auto_ads: true
20+
show_ads: true
21+
1622
# Build settings
1723
markdown: kramdown
1824
highlighter: rouge

_includes/adsense-banner.html

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
{% if site.adsense.client and site.adsense.show_ads and jekyll.environment == 'production' %}
2+
<!-- AdSense 배너 광고 -->
3+
<div class="ad-container">
4+
<ins class="adsbygoogle"
5+
style="display:block"
6+
data-ad-client="{{ site.adsense.client }}"
7+
data-ad-slot="{{ include.slot | default: 'auto' }}"
8+
data-ad-format="auto"
9+
data-full-width-responsive="true"></ins>
10+
<script>
11+
(adsbygoogle = window.adsbygoogle || []).push({});
12+
</script>
13+
</div>
14+
{% endif %}

_includes/adsense.html

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
{% if site.adsense.client and site.adsense.show_ads and jekyll.environment == 'production' %}
2+
<!-- Google AdSense Auto Ads -->
3+
<script async src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js?client={{ site.adsense.client }}"
4+
crossorigin="anonymous"></script>
5+
{% if site.adsense.auto_ads %}
6+
<script>
7+
(adsbygoogle = window.adsbygoogle || []).push({
8+
google_ad_client: "{{ site.adsense.client }}",
9+
enable_page_level_ads: true
10+
});
11+
</script>
12+
{% endif %}
13+
{% endif %}

_layouts/default.html

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,9 @@
5959

6060
<!-- Google Analytics -->
6161
{% include analytics.html %}
62+
63+
<!-- Google AdSense -->
64+
{% include adsense.html %}
6265
</head>
6366

6467
<body>

_layouts/post.html

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,12 +48,18 @@ <h1 class="post-title">{{ page.title }}</h1>
4848
</div>
4949
</header>
5050

51+
<!-- 포스트 상단 광고 -->
52+
{% include adsense-banner.html %}
53+
5154
<div class="post-content">
5255
<div class="container">
5356
{{ content }}
5457
</div>
5558
</div>
5659

60+
<!-- 포스트 하단 광고 -->
61+
{% include adsense-banner.html %}
62+
5763
<footer class="post-footer">
5864
<div class="container">
5965
<!-- 네비게이션 -->

assets/css/main.css

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1679,6 +1679,33 @@ a:hover {
16791679
}
16801680
}
16811681

1682+
/* AdSense Styles */
1683+
.ad-container {
1684+
margin: 2rem 0;
1685+
text-align: center;
1686+
border-top: 1px solid var(--border-color);
1687+
border-bottom: 1px solid var(--border-color);
1688+
padding: 1rem 0;
1689+
background-color: var(--background-secondary);
1690+
}
1691+
1692+
.ad-container::before {
1693+
content: "Advertisement";
1694+
display: block;
1695+
font-size: 0.75rem;
1696+
color: var(--text-secondary);
1697+
margin-bottom: 0.5rem;
1698+
text-transform: uppercase;
1699+
letter-spacing: 0.5px;
1700+
}
1701+
1702+
@media (max-width: 768px) {
1703+
.ad-container {
1704+
margin: 1.5rem 0;
1705+
padding: 0.75rem 0;
1706+
}
1707+
}
1708+
16821709
@media (max-width: 480px) {
16831710
.main-content {
16841711
margin-top: 90px !important; /* 작은 모바일에서는 약간 줄임 */

0 commit comments

Comments
 (0)