mmistakes / minimal-mistakes

:triangular_ruler: Jekyll theme for building a personal site, blog, project documentation, or portfolio.
https://mmistakes.github.io/minimal-mistakes/
MIT License
12.34k stars 25.51k forks source link

Google AdSense support #404

Closed gyandeeps closed 8 years ago

gyandeeps commented 8 years ago

First, Thanks for the great web template. :+1:

Based on the 3.3.3 release, I have been using this template on my website here I can see the _config.yml file has a spot for google ad id information here but its not getting used any where.

Am i missing something here or is this functionality not available?

mmistakes commented 8 years ago

Nope you're not missing anything. Those were just placeholders that I didn't end up using and forgot to remove. Adsense works just fine without it. Simply copy/paste the script code Google gives you into a layout or include where you want it to appear.

For the theme's demo site I dropped it in right above the footer if you want to see a live example.

gyandeeps commented 8 years ago

In the previous version, it used to put the ads for you. Do you think its should do it now also?

mmistakes commented 8 years ago

With this newer version there are custom head and footer includes so you can copy/paste in AdSense scripts (and other things).

I found that's more flexible. Simply take the script Google gives you after setting up your ad unit and paste it into footer/custom.html, in default.html layout (as I've done with the demo site), or anywhere else you'd prefer ads to appear.

If you check out the demo site (gh-pages branch) you can see how I handled it, using the responsive ad unit. These tend to work better with the theme since they adapt to various screen sizes (mobile, tablet, etc.) without overflowing the parent container.

    <script async src="//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script>
    <div align="center" style="margin: 1em 0;">
    <ins class="adsbygoogle"
         style="display:block; border-bottom: initial;"
         data-ad-client="ca-pub-7328585512091257"
         data-ad-slot="3049671934"
         data-ad-format="auto"></ins>
    </div>
    <script>
    (adsbygoogle = window.adsbygoogle || []).push({});
    </script>
DeveloperPaul123 commented 5 years ago

@mmistakes Is this still the way to do it if you're using minimal mistakes as a remote theme?

mmistakes commented 5 years ago

@DeveloperPaul123 Yes.

fredrikj31 commented 3 years ago

@mmistakes If I use the remote theme, how do I add content to the custom header file, when I have no access to the _layout folder when using the remote theme? Is there something I have missed?

mmistakes commented 3 years ago

@fredrikj31 https://jekyllrb.com/docs/themes/#overriding-theme-defaults

fredrikj31 commented 3 years ago

@fredrikj31 https://jekyllrb.com/docs/themes/#overriding-theme-defaults

Ohhh thanks. I think I had overseen that on the docs. Thanks a lot

cortix commented 1 year ago

With this newer version there are custom head and footer includes so you can copy/paste in AdSense scripts (and other things).

I found that's more flexible. Simply take the script Google gives you after setting up your ad unit and paste it into footer/custom.html, in default.html layout (as I've done with the demo site), or anywhere else you'd prefer ads to appear.

If you check out the demo site (gh-pages branch) you can see how I handled it, using the responsive ad unit. These tend to work better with the theme since they adapt to various screen sizes (mobile, tablet, etc.) without overflowing the parent container.

    <script async src="//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script>
    <div align="center" style="margin: 1em 0;">
    <ins class="adsbygoogle"
         style="display:block; border-bottom: initial;"
         data-ad-client="ca-pub-7328585512091257"
         data-ad-slot="3049671934"
         data-ad-format="auto"></ins>
    </div>
    <script>
    (adsbygoogle = window.adsbygoogle || []).push({});
    </script>

When I tested my website on my old laptop(15.6 inc), I noticed that the design of the sidebar with the google ad was slightly distorted. When I remove the google ad from the sidebar, the problem goes away. I did what you said but the problem still persists. You can see the screenshots below.

I tested my website on google, safari and opera;

chrome : 108.0.5359.125 (64 bit) firefox : 108.0.1 (64 bit) opera: version 94.0.4606.38

hasancelik org-1 hasancelik org-2