h5ai
h5ai copied to clipboard
How Can i add Adsense on H5Ai?
i always check googl about adsense. but i can't find about adsense on H5AI. HELP ME Guys:0
Custom Header/Footer is the easiest way.
Ref #654
just add raw adsense code in to header?
Or footer, yes. See https://github.com/lrsjng/h5ai/blob/44e53ab213d37f45df2acac01e957c67ec06f8a7/src/_h5ai/private/conf/options.json#L104-L111
Hmm I just add my code in _h5ai.header.html. but still i can't see any ad on my site! `
Dobob's Public Server.
public download server! :)
Just Click the File and you can download the file!
Here my page source. can you correct my code? i can see the ad on _h5ai.header.html but i can't see on H5AI. https://down.dobobwiki.com
It's harder than i thought. You will need to edit source files!
- Create file in public/js/lib/ext/google-ads.js: (change ca-pub to your ca-pub key)
const {dom, awaitLoad} = require('../util');
const event = require('../core/event');
const allsettings = require('../core/settings');
const win = global.window;
const settings = Object.assign({}, {});
const init = () => {
const script = '<ins class="adsbygoogle"\n' +
' style="display:block"\n' +
' data-ad-client="ca-pub-XXXXXXXXX"\n' +
' data-ad-slot="6586687715"\n' +
' data-ad-format="auto"></ins>\n';
dom(script).preTo('body');
(adsbygoogle = win.adsbygoogle || []).push({});
};
init();
- Edit public/js/lib/main/index.js and add:
require('../ext/google-ads');
- Edit private/php/pages/page.tpl.pug and add (line 18 after
script(src!='...
):
script(src="//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js")
- Build
npm run build
It's just proof of concept, so feel free to modify as you need.
Since the code is updated, maybe I cannot find where is "private/php/pages/page.tpl.pug". I follow the instruction in "_h5ai/private/conf/options.json" `/* Resources.
Additional script and style tags added to all pages. Paths not beginning
with "http://", "https://" or "/" will be looked up relative to
"_h5ai/public/ext/" (no check for existence).
- scripts: array of strings
- styles: array of strings
*/`
and indicate my js file directory, but Google Adsense cannot work. What else should I do?
I added a-ads to my site, however, it was very troublesome, and with fastBrowsing enabled, The ad does not refresh which causes the user to count as 1 view, despite them browsing and opening different pages
Is there a way that doesn't involve editing source? Especially as I don't use adsense the above example won't work
I use AdSterra