Add AdSense to Jekyll Blog | Generated by AI
Question: How do I add Google AdSense to my Jekyll blog (lzwjava/jekyll-ai-blog) to monetize it?
Answer:
Your site is static Jekyll on GitHub Pages, so AdSense integration is just a script tag + ads.txt. No SDK, no server. Here’s the exact diff based on your repo’s actual structure.
1. Apply for AdSense first — you need approval before ads render. Go to ads.google.com, add lzwjava.github.io as a site, wait for review (can take days-weeks). You’ll get a publisher ID like pub-1234567890123456.
2. Add ads.txt at repo root (required by Google, or you lose revenue to “unauthorized sellers” warnings):
cat > /path/to/repo/ads.txt << 'EOF'
google.com, pub-<PLACEHOLDER_PUB_ID>, DIRECT, f08c47fec0942fa0
EOF
3. Add Auto Ads script to <head> in _layouts/default.html — insert right after your existing GoatCounter script, before </head>:
<script data-goatcounter="https://lzwjava.goatcounter.com/count"
async src="//gc.zgo.at/count.js"></script>
+
+ <!-- Google AdSense -->
+ <script async src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js?client=ca-pub-<PLACEHOLDER_PUB_ID>"
+ crossorigin="anonymous"></script>
</head>
That alone enables Auto Ads (Google decides placement). If you want more control and better revenue, add manual in-article units.
4. Manual in-article ad unit — in _layouts/post.html, drop a unit right before the closing <hr> after `<main id="content" class="main-content post-content" role="main">
85B Model on 4×P40 | Generated by AI
Question: Can 4×Tesla P40 (24GB ×4 = 96GB VRAM) directly run an 85B parameter model?
Answer:
Yes, technically you can run an 85B model on 4×P40, but not in FP16. You need quantization, and performance will be limited.
Let’s calculate.
VRAM requirement
An 85B parameter model:
FP16
85B params × 2 bytes
= 170GB
Need:
170GB + KV cache + runtime overhead
≈ 180GB+
❌ 96GB cannot fit.
INT8
85B × 1 byte
≈ 85GB
Add overhead:
85GB + KV cache
≈ 90-100GB
Borderline.
4×P40:
24GB × 4 = 96GB
Maybe possible with aggressive memory management, but tight.
4-bit quantization (realistic)
85B × 0.5 byte
≈ 42.5GB
Add:
+ model metadata
+ KV cache
+ runtime
Usually:
50-60GB
So:
4×P40 96GB
has plenty of room.
Examples:
Llama 3.1 70B Q4
Qwen 72B Q4
DeepSeek 67B Q4
are comfortable.
85B Q4 should also fit.
But speed is the issue
P40 has no Tensor Cores.
Your compute:
1 × P40
≈ 12 TFLOPS FP32
4 × P40
≈ 48 TFLOPS FP32
Compare:
RTX 4090
≈ 83 TFLOPS FP32
But LLM inference is not only FLOPS; memory bandwidth matters.
P40:
346 GB/s × 4
≈ 1.4 TB/s
A 4090:
1 TB/s
So multi-P40 has decent bandwidth.
Multi-GPU inference
You need tensor parallelism:
85B model
model layers
|
---------------------
| | | |
P40 P40 P40 P40
24G 24G 24G 24G
Software:
llama.cpp
Example:
./llama-server \
-m qwen-85b-q4.gguf \
-ngl 999 \
--tensor-split 1,1,1,1
vLLM
CUDA_VISIBLE_DEVICES=0,1,2,3 \
vllm serve model \
--tensor-parallel-size 4
Expected performance
Rough estimate:
| Hardware | 70B Q4 tok/s |
|---|---|
| RTX 4090 | ~20-35 tok/s |
| 2×3090 | ~30-50 tok/s |
| 4×P40 | ~5-15 tok/s |
| CPU only | <5 tok/s |
So 4×P40 is a capacity machine, not a speed machine.
For a home AI server:
RTX 4070
↓
training / coding / experiments
4×P40 96GB
↓
always-on LLM inference server
↓
70B-85B quantized models
is actually a reasonable architecture.
The sweet spot is probably 2×P40 or 4×P40 + llama.cpp + GGUF, because the biggest limitation is not VRAM — it is the lack of Tensor Cores and older CUDA architecture.
</main>
` (post-content boundary, decent CTR spot):
{{ content }}
+ <div class="ad-container" style="margin: 24px 0; text-align:center;">
+ <ins class="adsbygoogle"
+ style="display:block"
+ data-ad-client="ca-pub-<PLACEHOLDER_PUB_ID>"
+ data-ad-slot="<PLACEHOLDER_SLOT_ID>"
+ data-ad-format="fluid"
+ data-ad-layout-key="-gw-3+1f-3d+2z"></ins>
+ <script>(adsbygoogle = window.adsbygoogle || []).push({});</script>
+ </div>
+
<hr>
Get data-ad-slot from AdSense dashboard → Ads → By ad unit → In-article ad → create one.
5. Deploy — your existing GH Actions workflow (gh-pages.yml) handles the build/deploy, no changes needed there. Just commit and push.
Notes specific to your setup:
google_analytics: "UA-66656236-1"in_config.ymlis Universal Analytics — that’s been sunset since 2023 and does nothing now. Worth swapping for GA4 or dropping it since you already have GoatCounter for real analytics.- Since your blog is bilingual (
-en/-zh) and AI-translated content, be aware AdSense’s policy on “auto-generated content” — pages flagged aspage.generated: trueandpage.translated: truein your frontmatter could get flagged in a manual review if there’s too much unedited AI output. Not a hard blocker but worth knowing. - At current traffic (2 stars/1 watcher on the repo isn’t a traffic signal, but if your
notespages — 1992 of them — get real search traffic, that long-tail content is actually where AdSense earns most, since it’s indexed niche technical content).
Alternative worth considering given your AI-agent background: skip display ads entirely and monetize via a sponsor/affiliate block (e.g. tools you build — ww, iclaw, zz — or GPU/consulting CTA) since your traffic profile (engineers reading technical notes) converts far better to consulting leads than to $0.50 CPM display ads.
References: