Example Page
Quarto Extension for Google Adsense In-Article Ad Unit Support
An Example
Hi world! Below this text you can find an ad by replacing it with a javascript <script> block. What do you think would be below this?
Above this line is an ad, with a label under it that says “Advertisement”. Nothing will show up above it because you have to specify your own credentials first in _quarto.yml. You also need to accept the cookie consent for ads and targeting cookies as well.
Try inspecting this page by pressing Ctrl + Shift + I on Windows or Cmd + Shift + I on a Mac. You can also try with F12 or right-clicking on “Advertisement” and choosing Inspect. You will see a <ins> tag and depending on your cookie preferences you might see an iframe with the ad in it. But for now it is not there since we have not specified Google Adsense credentials yet in this website.
Installing
quarto install extension jskherman/inadsenseThis will install the extension under the _extensions subdirectory. If you’re using version control, you will want to check this in this directory.
Usage
It is required that you need to specify cookie-consent and Google Adsense credentials in _quarto.yml first before you can insert ad units.
Example:
website:
cookie-consent:
type: express # or implied
adsense:
client: "ca-pub-xxxxxxxxxxxxxxxx" # data-ad-client
slot: "1234567890" # data-ad-slotYou can get your credentials by signing up for a Google Adsense account, going to the Ads option on the left sidebar and creating a new in-article ad. For more information please refer to how this was achieved via Hugo by at godo.dev: Inserting an Ad Unit to Hugo Content without Shortcode

After that, you can then use the shortcode in your qmd files to embed ad units in pages.