Google AdSense Implementation Guide
Google AdSense Implementation Guide
Overview
Google AdSense has been integrated into your Jekyll website with ads placed in the following locations:
- Sidebar: Below the timeline navigation (both desktop and mobile)
- Post Top: Below the post title and metadata
- Post Bottom: Above the previous/next post navigation buttons
Configuration
Step 1: Update AdSense Configuration
Edit the file _data/adsense.yml
and replace the placeholder values:
google_adsense:
enabled: true
publisher_id: "ca-pub-YOUR_ACTUAL_PUBLISHER_ID" # Replace with your AdSense Publisher ID
ad_slots:
sidebar: "YOUR_SIDEBAR_AD_UNIT_ID" # Replace with your sidebar ad unit ID
post_top: "YOUR_POST_TOP_AD_UNIT_ID" # Replace with your post top ad unit ID
post_bottom: "YOUR_POST_BOTTOM_AD_UNIT_ID" # Replace with your post bottom ad unit ID
Step 2: Get Your AdSense Publisher ID
- Log in to your Google AdSense account
- Go to Account > Account Information
- Find your Publisher ID (starts with “ca-pub-“)
Step 3: Create Ad Units
- In AdSense, go to Ads > By ad unit
- Create three ad units:
- Sidebar Ad: Recommended size - Square (300x250) or Vertical Banner (120x600)
- Post Top Ad: Recommended size - Banner (728x90) or Large Rectangle (336x280)
- Post Bottom Ad: Recommended size - Banner (728x90) or Large Rectangle (336x280)
- Copy each ad unit ID to the configuration file
Step 4: Testing
To disable ads during development, set enabled: false
in _data/adsense.yml
.
File Structure
_data/
adsense.yml # AdSense configuration
_includes/
adsense-head.html # AdSense script include
adsense-sidebar.html # Sidebar ad code
adsense-post-top.html # Post top ad code
adsense-post-bottom.html # Post bottom ad code
assets/css/
adsense.css # AdSense styling
Customization
Styling
Modify assets/css/adsense.css
to adjust the appearance of ad containers:
- Background colors
- Border styles
- Spacing and margins
- Mobile responsiveness
Ad Placement
The ads are included using Jekyll’s include system:
- `
` - For sidebar ads
- `
` - For post top ads
- `
` - For post bottom ads
Responsive Design
The current implementation uses:
data-full-width-responsive="true"
for automatic responsive sizing- CSS media queries for mobile-specific adjustments
- Flexible ad formats that adapt to container size
AdSense Policies Compliance
Important Considerations:
- Content Policy: Ensure your content complies with AdSense content policies
- Placement Policy: Ads are placed in compliance with AdSense placement policies
- Traffic Quality: Only use legitimate traffic sources
- Click Policy: Never click on your own ads or encourage others to do so
Recommended Practices:
- Monitor ad performance regularly in AdSense dashboard
- Test different ad sizes and formats
- Ensure ads don’t negatively impact user experience
- Keep ad-to-content ratio balanced
Troubleshooting
Ads Not Showing:
- Check that
enabled: true
in_data/adsense.yml
- Verify Publisher ID and Ad Unit IDs are correct
- Ensure your site is approved by AdSense
- Check browser console for JavaScript errors
Layout Issues:
- Adjust CSS in
assets/css/adsense.css
- Test on different screen sizes
- Ensure ads don’t break site layout on mobile devices
Performance Considerations
- AdSense script loads asynchronously to avoid blocking page render
- CSS includes minimum height to prevent layout shift
- Responsive ads adapt to different screen sizes automatically