Table of Contents

Adding Google AdSense in DukoWiki

To add Google AdSense in your DokuWiki in a easy way, you need to first install the DokuWiki Bootstrap3 Template, and then adding HTML Hooks with your AdSense codes.

Install Bootstrap3 Template

Bootstrap3 Template can be easily install in the DokuWiki Admin page.

  1. Go to Admin Page
  2. Select Extension Manager
  3. Select Search and Install tab
  4. Search with keyword bootstrap template
  5. Next to Bootstrap3 Template, click the Install button.

Activate Bootstrap3 Template

Now you need to activate the newly installed Bootstrap3 Template

  1. Go to Admin Page
  2. Select Configuration Manager
  3. Under basic section, change the template to bootstrap3
  4. Go to the end of the page, click Save button to save.

Adding the Google AdSense Ads

Now you need to go to your AdSense account, and create a new ads unit. After creating the ads unit, copy the Ad code. It should be something look like:

<script async src="//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script>
<!-- your.ads.name -->
<ins class="adsbygoogle"
     style="display:block"
     data-ad-client="ca-pub-xxxxxxxxxxxxxxx"
     data-ad-slot="xxxxxxxxxxx"
     data-ad-format="auto"
     data-full-width-responsive="true"></ins>
<script>
(adsbygoogle = window.adsbygoogle || []).push({});
</script>

Now that everything is ready, let's add our ads to DukoWiki.

  1. Open a terminal on your server, or ssh to it.
  2. Change to the DokuWiki directory you installed it. cd /var/www/dokuwiku for example.
  3. Go to directory ./lib/tpl/bootstrap3 cd ./lib/tpl/bootstrap3. This is the boostrap3 template directory.
  4. Create a file called header.html. This is one of the html hook we can add for the boostrap3 template. You can use vim or nano, or the any text editor you like to do so. Note that you need to use sudo here.
    user@server:/var/www/dokuwiki/lib/tpl/bootstrap3$ sudo vim header.html
  5. Inside this header.html file, paste the Google Ad code you obtain from the Adsense site.
  6. Save the file.
  7. Now go to your DokuWiki page, and you should see your ads in the page header.
  8. You might add the ads in other places like footer.html, topheader.html, … The html hooks details can be found here https://www.dokuwiki.org/template:bootstrap3:hooks.