Putting HTML from a outside sources into your blog

This article is about how to put HTML or Javascript code from 3rd parties into your blog.


Unlike some blogging tools, Blogger allows you to put HTML code from third-party sites that they are not integrated with (eg PayPal, Flickr, Amazon, Facebook, Twitter, LinkedIn), into your blog.

The only code that you can use this way is HTML and Javascript: there is no way to add PHP, SQL or any other type of code.  (The only exception might be if you can host and execute this code elsewhere, and call it and receive output with Javascript - I haven't tried this, have no idea if it's possible in practice.).

If you have a layout or designer template (ref   What type of template do you have?), there are three ways to put outside code into your blog:
  • Option one:  In a widget/gadget.
    These can be placed in any location the Design > Page Elements screen gives you access to - usually go into the header, footer or sidebar.
  • Option two:  Inside a specific Post (or Page)
    This means that the effect of the code will be shown every time the post is viewed
  • Option three:  In the blog's layout template
    This gives you most control over where and how the item appears, but is also the hardest.
These three options are described in detail in the sections below.

If you are using a dynamic template, then you face more limitations:  you can put code into posts/pages for sure, but (for the moment anyway) there are limits to what gadgets can be added.   And editing your template may be more challenging, because the template-structure is so different.

    By letting us put 3rd-party code into our Blogger is giving us the responsibility for making sure that only code from trust-worthy sources is used.

    If you install code from unreliable sources, you may find that your blog is "hacked" in some way.

    Every time that someone wants you to install something to your blog, think very carefully about how much you should trust them.

    Option 1: Putting third party code in a gadget

    • Copy the code from the third-party site.
    • In Blogger, choose Layout > Add a Gadget > HTML-Javascript Note:  Use the gadget created by Blogger which is in the Basic list.  Currently you need to see to scroll down the list of gadget to see it. 
      Don't use the search tool to find it, because currently (2/11/10), it returns a 3rd party gadget that doesn't work.)
    • Paste the code into the Contents field.
    • Enter a title, if you want the gadget to have one
    • Press Save.  
    • Drag-and-drop the new gadget to where you want it to appear.
    • Save the layout

    Some sites either give you the HTML, and also button that will put their gadget (etc) directly into your blog.   I only use these type of buttons if the address bar in the screen that opens has an address starting with blogger.com:  if it has something else, then the third-party site may be collecting your Google account password along the way

    Option Two: Put third-party code inside a post

    • Copy the code from the third party site
    • Go to blogger and Edit the Post (or Page) that you want to put it on
    • Switch into HTML mode
    • Paste the code in at the place where you want the item to go.
      If you are not familiar with HTML, it may help to put in some marker text, eg XXX, at the place where you want the product link while you're still in Compose mode.  Then switch to Edit HTML mode, find the marker text using your browser's search tool (eg Ctrl/F), and replace it with the third-part code.
    • Switch back to Compose mode
      This sometimes lets you see the 3rd party item within the post editor - although sometimes it just shows as a blank box, or even just as a blank line (I sometimes surround lines like this with some marker text, eg xxx, while I'm editing the post, to make sure I don't accidentally over-type of the code.
      If you forget to go back to Compose mode before you press Publish, you may get confused the next time you edit a post.

    Option Three: Put the third-party code into your template

    You should only use this option if you are very familiar with how your template works, and you accept the disadvantages of editing it.

    Also, be aware that for some third-parties, putting the code into your template can over-ride controls that usually come with it (eg for AdSense, only displaying up to three ad-units and three link-units per screen).  For other types of code, the tweaks that are needed to make it work within Blogger may break the other parties terms-and-conditions (eg if they say you cannot change the code at all).   You need to weigh up the risks and issues involved for each individual third party.
    • Edit your template in the usual way
    • Work out where exactly the code needs to go, and put it there.
    • Preview the change, to make sure it works
    • Save the template

      Related Articles:

      Editing your blog's template:  advantanges and disadvantages

      Types of blogger template

      Enabling a mobile template for your blog

      Choosing which gadgets are shown on your mobile-template view

      Blogger and other Google products

      Blogger and some key non-Google products

      Amazon integration with Blogger

      Putting Chitika ads onto your blog


      Post a Comment

      Home - About - Order - Testimonial
      Copyright © 2010 Tips Blogging All Rights Reserved.