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.

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.

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.

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="//"></script>
<!-- -->
<ins class="adsbygoogle"
(adsbygoogle = window.adsbygoogle || []).push({});

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
  • adding_google_adsense.txt
  • Last modified: 2019/09/06 09:53
  • by chongtin