Hexo - Icarus using Google AdSense

There are several ways to making money with your blog. One way is Google AdSense.
Most blogs use Next theme to embed Google AdSense, but my blog used Icarus theme.

After some research, I found a way to embed Google AdSense with Icarus theme.
Steps as follow.

Only for Icarus 2.X

Step 1: Register Google AsSense account

Before register,your blog must have enough articles.

Visit the Google AdSense sign-up page and sign in with your existing Google account.

Enter the full URL of your website’s home page.

Fill in the name of the blog, country of origin and agree to the terms and conditions of use of the platform.

Step 2: Verify Blog

After registered, Google will verify your blog.

Google AdSense will send a script ,add this script in the tag content. (/hexo/theme/hexo-theme-icarus/layout/layout.ejs)

layout.ejs
1
2
3
4
5
6
7
<!DOCTYPE html>
<html <%- has_config('language') ? ' lang="' + get_config('language').substring(0, 2) + '"' : '' %>>
<head>
<%- _partial('common/head') %>
<script data-ad-client="ca-pub-xxxxxxxxxx" async src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script>
</head>
<body> ... </body>

After that, check verify button in Google AdSense website.

At the end of the registration process, Google will send an envelope to your address with a verification code. This may take up to three days or a week.

Step 3: Add Ads

After verified, we use the type「Block of links」to embed on my blog.

Goolge AdSense will give you a script.

Add this script in your card widget.

Ex:

Footer : /hexo/theme/hexo-theme-icarus/layout/common/footer.ejs

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
<footer class="footer">
<div class="container">
<div class="level">
</div>
<script async src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script>
<!-- Landscape Ads -->
<ins class="adsbygoogle"
style="display:block"
data-ad-client="ca-pub-xxxxxxxx"
data-ad-slot="xxxxxxx"
data-ad-format="auto"
data-full-width-responsive="true"></ins>
<script>
(adsbygoogle = window.adsbygoogle || []).push({});
</script>
</div>
</footer>

Profile : /hexo/theme/hexo-theme-icarus/layout/widget/profile.ejs

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
<div class="card widget">
<div class="card-content">
<script async src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script>
<!-- Square Ads -->
<ins class="adsbygoogle"
style="display:block"
data-ad-client="ca-pub-xxxxxxxxx"
data-ad-slot="xxxxx"
data-ad-format="auto"
data-full-width-responsive="true"></ins>
<script>
(adsbygoogle = window.adsbygoogle || []).push({});
</script>
</div>
</div>

Link : /hexo/theme/hexo-theme-icarus/layout/widget/link.ejs

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
<div class="card widget">
<div class="card-content">
<script async src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script>
<!-- Square Ads -->
<ins class="adsbygoogle"
style="display:block"
data-ad-client="ca-pub-xxxxxxxxx"
data-ad-slot="xxxxx"
data-ad-format="auto"
data-full-width-responsive="true"></ins>
<script>
(adsbygoogle = window.adsbygoogle || []).push({});
</script>
</div>
</div>

After 30 min. , you will see the Ads in your blog.

Author

Nick Lin

Posted on

2019-10-25

Updated on

2023-01-18

Licensed under


Comments