Installation Guide for Quarto Adsense Extension
Installation
To seamlessly integrate the adsense extension into your Quarto project, follow these straightforward steps:
Open Your Terminal: Open your terminal or command prompt.
Execute the Installation Command: Run the following command to automatically download and install the extension:
quarto add coatless-quarto/adsenseThis command installs the
adsenseextension in the_extensionssubdirectory of your Quarto project. If you’re utilizing version control, make sure to include this directory in your repository.
Google Adsense Setup: Adding ads.txt
To ensure smooth integration with Google Adsense, it’s essential to create a standalone file named ads.txt within your project directory that identifies the domain as being authorized to serve ads. Follow these steps to include your Google Publisher ID:
Create
ads.txtFile: In the root of your project, create a new file namedads.txt.Add Google Publisher ID: Open
ads.txtand insert the following line, replacingXXXXXXXXXXXXXXXXwith your actual Google Publisher ID:google.com, pub-XXXXXXXXXXXXXXXX, DIRECT, f08c47fec0942fa0This line informs Google’s web crawler about your association with the provided Publisher ID. For an example, please see the
docs/ads.txt.Save and Include in Version Control: Save the changes to
ads.txtand ensure that the file is included in your version control system if you’re using one.**Register
ads.txtin _quarto.yml:** Open the_quarto.ymlconfiguration and add theresourcesline under the project key.project: type: website # default, book, revealjs resources: - ads.txtThis ensures the additional file resources are copied to the output directory.
This step is crucial for validating your ownership of the website and enabling a smooth interaction between your Quarto-generated content and Google Adsense. Remember to replace XXXXXXXXXXXXXXXX with your specific Google Publisher ID.
Usage
You can configure the adsense extension in either of the following ways:
Global Configuration Using a Configuration File: Set up the extension globally by incorporating the relevant configuration in either the
_quarto.ymlor_metadata.ymlfile. This ensures consistent usage across all documents in your project.Document-specific Configuration in YAML Header: Customize the extension settings for individual documents by adding configuration details to the YAML header of the respective Quarto document. This approach allows for fine-tuned control on a per-document basis.
Select the configuration method that best suits your project’s needs to learn more!