|
| 1 | +# Google AdSense Configuration with AMP Auto Ads |
| 2 | + |
| 3 | +## 📋 Summary |
| 4 | +Google AdSense configuration with AMP (Accelerated Mobile Pages) Auto Ads support has been implemented according to Google specifications. |
| 5 | + |
| 6 | +## ✅ Implementation Completed |
| 7 | + |
| 8 | +### Step 1: AMP Script in `<head>` |
| 9 | +- ✅ Added in `_includes/head-adsense.html` |
| 10 | +- ✅ Script: `https://cdn.ampproject.org/v0/amp-auto-ads-0.1.js` |
| 11 | +- ✅ Conditional: Only loads if `site.adsense.amp_enabled: true` |
| 12 | + |
| 13 | +### Step 2: `<amp-auto-ads>` Element after `<body>` |
| 14 | +- ✅ Implemented via JavaScript for Jekyll/Chirpy compatibility |
| 15 | +- ✅ File: `assets/js/amp-auto-ads.js` |
| 16 | +- ✅ Configuration: Automatic client ID from `_config.yml` |
| 17 | + |
| 18 | +## 🔧 Configuration in `_config.yml` |
| 19 | + |
| 20 | +```yaml |
| 21 | +google_adsense: "ca-pub-7596549899792751" |
| 22 | +adsense: |
| 23 | + enabled: true # General AdSense |
| 24 | + auto_ads: true # Traditional automatic ads |
| 25 | + amp_enabled: true # 🆕 AMP Auto Ads (NEW) |
| 26 | + show_in_posts: true |
| 27 | + show_in_pages: false |
| 28 | +``` |
| 29 | +
|
| 30 | +## 📁 Modified/Created Files |
| 31 | +
|
| 32 | +1. **`_config.yml`** - Added `amp_enabled: true` |
| 33 | +2. **`_includes/head-adsense.html`** - AMP script in head |
| 34 | +3. **`_includes/head-custom.html`** - JavaScript configuration |
| 35 | +4. **`assets/js/amp-auto-ads.js`** - 🆕 AMP Auto Ads logic |
| 36 | +5. **`assets/css/adsense.css`** - AMP styles |
| 37 | +6. **`_includes/amp-auto-ads.html`** - 🆕 AMP template (backup) |
| 38 | + |
| 39 | +## 🎯 How It Works |
| 40 | + |
| 41 | +1. **Head**: AMP library and JS configuration loads |
| 42 | +2. **Body**: JavaScript inserts `<amp-auto-ads>` at content beginning |
| 43 | +3. **Client**: Automatically uses `ca-pub-7596549899792751` |
| 44 | + |
| 45 | +## ⚙️ Functionality Control |
| 46 | + |
| 47 | +To **enable** AMP Auto Ads: |
| 48 | +```yaml |
| 49 | +adsense: |
| 50 | + amp_enabled: true |
| 51 | +``` |
| 52 | + |
| 53 | +To **disable** AMP Auto Ads: |
| 54 | +```yaml |
| 55 | +adsense: |
| 56 | + amp_enabled: false |
| 57 | +``` |
| 58 | + |
| 59 | +## 📝 Important Notes |
| 60 | + |
| 61 | +- Ads may take **up to 1 hour** to appear |
| 62 | +- Compatible with Jekyll + Chirpy theme |
| 63 | +- Does not interfere with existing AdSense ads |
| 64 | +- Fully responsive for mobile devices |
| 65 | + |
| 66 | +## 🔍 Verification |
| 67 | + |
| 68 | +1. Run: `./tools/run.sh` for local server |
| 69 | +2. Inspect element: Look for `<amp-auto-ads>` in DOM |
| 70 | +3. Console: Verify no AMP errors |
| 71 | +4. Wait up to 1 hour to see ads in production |
| 72 | + |
| 73 | +--- |
| 74 | +**Implemented**: {{ "now" | date: "%Y-%m-%d %H:%M" }} |
| 75 | +**AdSense Client**: ca-pub-7596549899792751 |
0 commit comments