Ads and sponsors
Ads are static markup in site.config.ts — no script, no ad network. Each placement is one
boolean under ads; ads.page.enabled builds the /advertise/ page of rates.
-
Turn on the page and one placement.
site.config.ts ads: {contactEmail: 'ads@acme.com',page: { enabled: true, note: 'Placements run for a calendar month.' },topBanner: { enabled: true, text: 'Sponsor Acme — your product in front of every reader.', url: 'https://sponsor.example' },rates: [{ slot: 'topBanner', price: '$99 / month', blurb: 'One line under the header, on every page.' }],},pnpm check:configanswerssite.config.ts OK — <name> (<url>). Aurlorlogomust be anhttps://URL or a/-rooted path. -
Build and deploy.
Terminal pnpm deployThe build’s
zero-js:line still ends— ok.
Verify
Section titled “Verify”| What to check | Where | You should see |
|---|---|---|
| The placement | curl -s https://<your domain>/ | grep -o 'data-ad="[a-z-]*"' |
data-ad="top-banner"; the others are sponsors, inline-card, corner |
| The rates | https://<your domain>/advertise/ |
the rates table, a live badge per enabled placement, an Email button |
| The footer | any page | an Advertise link |
| The rel | page source | rel="sponsored noopener" on every ad link |


Worth knowing
Section titled “Worth knowing”advertiseis reserved: no listing or category base can use it.- The Email button is a
mailto:toads.contactEmail, falling back tosite.contactEmail, subjectAdvertising on <site name>. - A sponsor is
name,url, optionallogoandtagline; other placements takename,tagline,url,logo. Add one tosite.config.tsand deploy. corneronly renders from themdbreakpoint up.- A placement runs until you edit the file again. The demo’s prices are placeholders.
When it is off or degraded
Section titled “When it is off or degraded”| State | Visitor sees | Fix |
|---|---|---|
| All off (default) | no ads, no footer link, /advertise/ is a 404 |
— |
A placement on, page.enabled off |
without url, the ad links to /advertise/: a 404 |
set url, or enable the page |
sponsors.enabled with empty items |
nothing renders, no live badge | add an item |
A grid no longer than every |
no in-grid card | expected |
A url without https:// or a leading / |
pnpm check:config fails naming the field |
fix the value |
Configuration
Section titled “Configuration”ads.contactEmail, ads.page.enabled, ads.page.intro, ads.page.note, the four placements ads.topBanner, ads.sponsors, ads.inlineCard and ads.corner, and the ads.rates table — ads.
Directorysrc/
Directorycomponents/ads/
- AdBanner.astro
topBanner - Sponsors.astro
sponsors - AdCard.astro
inlineCard - CornerAd.astro
corner
- AdBanner.astro
- lib/ads.ts
AD_SLOTS,activeSlots(),withInlineSlots() - pages/[advertise].astro the rates page
- layouts/Base.astro mounts the banner and the corner card
- templates/HomePage.astro mounts the sponsor wall
- components/listing/Grid.astro mounts the in-grid card
- components/site/Footer.astro the Advertise link
- config/defaults.ts
DEFAULT_ADS
- site.config.ts the demo’s
adsblock