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.
- Go to
Admin Page
- Select
Extension Manager
- Select
Search and Install
tab - Search with keyword
bootstrap template
- Next to Bootstrap3 Template, click the
Install
button.
Activate Bootstrap3 Template
Now you need to activate the newly installed Bootstrap3 Template
- Go to
Admin Page
- Select
Configuration Manager
- 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.
- Open a terminal on your server, or ssh to it.
- Change to the DokuWiki directory you installed it.
cd /var/www/dokuwiku
for example. - Go to directory ./lib/tpl/bootstrap3
cd ./lib/tpl/bootstrap3
. This is the boostrap3 template directory. - 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 usesudo
here.user@server:/var/www/dokuwiki/lib/tpl/bootstrap3$ sudo vim header.html
- Inside this header.html file, paste the Google Ad code you obtain from the Adsense site.
- Save the file.
- 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.