So, classic templates are incompatible with new Blogger templates. New Blogger templates use "Page Elements" (widgets) but the places where you can insert widgets are rather limited. So what about if you need more flexibility than they allow?
- Google Widgets are always separated by dashed horizontal rules, which can be inappropriate if you want to blend your ads.
- You cannot insert widgets inside your blog post, so you need to edit template HTML code.
Of course you can use standard Blogger feature for adding AdSense ads between your posts (Blogger - Template - Page Elements - Blog Posts - Edit - Show Ads Between Posts). After that you can move these ads position using this technique. But sometimes it is not enough: for example you cannot specify channel, you cannot insert AdSense for referrals code. Also you are not able to insert ads from other ad networks (YSM, AdBrite, Chitika) with this method.
Maybe you already have tried to insert some javascript code into your teplate HTML, and on Preview/Save template got an error similar to this:
Your template could not be parsed as it is not well-formed. Please make sure all XML elements are closed properly.
XML error message: The content of elements must consist of well-formed character data or markup.
So why your template could be not valid when something changed? Here is the some of XML requirements:
- Documents must be well-formed.
- In XHTML every tag should have a matching end tag.
- Ampersands (&) used for marking entity names, so you cannot use & in your code. Instead of it it must be written as &
- Element and attribute names must be in lower case
- In XHTML, the script and style elements are declared as having #PCDATA content. As a result, < and & will be treated as the start of markup, and entities such as < and & will be recognized as entity references by the XML processor to < and & respectively
- If you are interested in more, the full XHTML specification is here.
HTML | XHTML |
---|---|
> | > |
< | < |
& | & |
" | " |
This change could be quite annoying if doing manually, so we have an online tool for doing this: HTML Encoder. Frankly speaking, purpose of this tool is not only converting HTML for Blogger templates. It just replaces all special HTML characters into their entities. This is the case we need exactly the same.
If you view HTML source of resulting blog pages in a browser, you will find the exact same AdSense code that Google provides, without any modification.
Since Google allows only certain number of ads per page, the remaining ads will not be shown if you have several post on same page. They have a logic in their javascript code to suppress the extra-ads display. But it can be reasonable to show not more than 3 posts on the blog's main page.
Disclaimer: Use at own risk. If you have concerns about inserting more than maximum number of ads allowed, you could contact the AdSense team and let them get back to you on their official stand.
Maximum number of AdSense ads, per page (from AdSense Policy):
Ad type | Max count |
---|---|
Context ad unit | 3 |
Link unit | 3 |
Referral unit | 3 |
Search box | 2 |
Hint: It may be more efficient to place your AdSense code enclosed into floating div, so you can style and align it with CSS any way you want:
Nevertheless, this method of inserting arbitrary code into template could be used not only for AdSense, Chitika, AdBrite but for any html/javascript (social bookmarking buttons ("Digg it", Stumbleupon button, etc.), any javascript widgets and so on). So if it can accomplished with Blogspot page elements, stick with them, if cannot, you can use the technique described above. <div style="float: right; margin: 10px;">
AdSense Code
</div>
This article was written by Max Bulber
0 comments:
Post a Comment