Cách Rút gọn link Google trong Blogspot

Cách Rút gọn link Google trong Blogspot

Cách Rút gọn link Google trong Blogspot
Nency
2016-11-05
Bài này mình chia sẻ cho các bạn cách rút gọn links google ngay trong trang bài viết của blog. Cách Rút gọn link Google trong Blogspot



Google URL Shortener tại goo.gl được sử dụng bởi các sản phẩm của Google để tạo URL ngắn mà có thể dễ dàng chia sẻ, Tweet, hoặc gửi qua Email cho bạn bè.

Các bước thực hiện như sau:

Bước 1:  Để hiển thị một URL ngắn ở dưới cùng của mỗi bài viết. Vào quản trị Blog--> Chọn Blog--> Mẫu-->Chỉnh sửa HTML

Bước 2: Tìm kiếm thẻ </style>

Bước 3: Dán đoạn Javascript dưới sau thẻ đóng </style>


<script type='text/javascript'>
    // Shorten Blogger post URLs using urltinyfy javascript API, by MS-potilas 2012
    // 
    //<![CDATA[
    function loadscript(filename) {
      var scr=document.createElement('script');
      scr.setAttribute("type","text/javascript");
      scr.setAttribute("src",filename);
      document.getElementsByTagName("head")[0].appendChild(scr);
    }
    var waitElm=null;
    function urltinyfyprompt_callback(response) {
      if(waitElm) waitElm.style.display="none";
      var txt="Short URL";
      if(response.title && response.title!="") txt+=' for "'+response.title+'"';
      else if(response.longurl && response.longurl!="") txt+=" for "+response.longurl;
      if(response.tinyurl && response.tinyurl!="")
        prompt(txt+":", response.tinyurl);
      else
        alert("Could not get short URL, try again later." + ((response.error && response.error != "") ? ("\nError: " + response.error) : ""));
    }
    function shortenUrl(elm, long_url, service) {
      waitElm=elm.parentNode.nextSibling;
      if(waitElm) waitElm.style.display="inline";
      loadscript("http://urltinyfy.appspot.com/"+service+"?unify=1&url="+encodeURIComponent(long_url) + "&callback=urltinyfyprompt_callback");
    }
    //]]>
    </script>

Bước 3: Chèn đoạn code dưới trên đoạn post-footer-line-3
<span class='shorturls'>Short URLs:
<a expr:onclick='&quot;shortenUrl(this, &amp;#39;&quot; + data:post.url + &quot;&amp;#39;, &amp;#39;googl&amp;#39;);return false;&quot;' href='javascript:void(0)' title='Click to get short URL'>goo.gl</a>,
<a expr:onclick='&quot;shortenUrl(this, &amp;#39;&quot; + data:post.url + &quot;&amp;#39;, &amp;#39;mcafee&amp;#39;);return false;&quot;' href='javascript:void(0)' title='Click to get short URL'>mcaf.ee</a>,
<a expr:onclick='&quot;shortenUrl(this, &amp;#39;&quot; + data:post.url + &quot;&amp;#39;, &amp;#39;cligs&amp;#39;);return false;&quot;' href='javascript:void(0)' title='Click to get short URL'>cli.gs</a>
</span><span style='display:none;'><img border='0' src='data:image/gif;base64,R0lGODlhEAALAPQAAP///wAAANra2tDQ0Orq6gYGBgAAAC4uLoKCgmBgYLq6uiIiIkpKSoqKimRkZL6+viYmJgQEBE5OTubm5tjY2PT09Dg4ONzc3PLy8ra2tqCgoMrKyu7u7gAAAAAAAAAAACH/C05FVFNDQVBFMi4wAwEAAAAh/hpDcmVhdGVkIHdpdGggYWpheGxvYWQuaW5mbwAh+QQJCwAAACwAAAAAEAALAAAFLSAgjmRpnqSgCuLKAq5AEIM4zDVw03ve27ifDgfkEYe04kDIDC5zrtYKRa2WQgAh+QQJCwAAACwAAAAAEAALAAAFJGBhGAVgnqhpHIeRvsDawqns0qeN5+y967tYLyicBYE7EYkYAgAh+QQJCwAAACwAAAAAEAALAAAFNiAgjothLOOIJAkiGgxjpGKiKMkbz7SN6zIawJcDwIK9W/HISxGBzdHTuBNOmcJVCyoUlk7CEAAh+QQJCwAAACwAAAAAEAALAAAFNSAgjqQIRRFUAo3jNGIkSdHqPI8Tz3V55zuaDacDyIQ+YrBH+hWPzJFzOQQaeavWi7oqnVIhACH5BAkLAAAALAAAAAAQAAsAAAUyICCOZGme1rJY5kRRk7hI0mJSVUXJtF3iOl7tltsBZsNfUegjAY3I5sgFY55KqdX1GgIAIfkECQsAAAAsAAAAABAACwAABTcgII5kaZ4kcV2EqLJipmnZhWGXaOOitm2aXQ4g7P2Ct2ER4AMul00kj5g0Al8tADY2y6C+4FIIACH5BAkLAAAALAAAAAAQAAsAAAUvICCOZGme5ERRk6iy7qpyHCVStA3gNa/7txxwlwv2isSacYUc+l4tADQGQ1mvpBAAIfkECQsAAAAsAAAAABAACwAABS8gII5kaZ7kRFGTqLLuqnIcJVK0DeA1r/u3HHCXC/aKxJpxhRz6Xi0ANAZDWa+kEAA7AAAAAAAAAAAA'/></span><div style='clear:both'/>


Shortener Url là việc tối ưu đường dẫn trong thế giới Internet quá nhiều url khác nhau.

Tổng kết: Việc chèn Code tạo Rút gọn link Google trong Blogspot tùy thuộc vào template của bạn chọn, có thể copy đoạn code ở bước 3 vào chỗ nào trong bai viết bạn muốn hiển thị, cách đặt của nó giống như cách trong bài Chèn comment Facebook vào Blogspot mới nhất. 

Chúc các bạn làm được như ý!




Cách Rút gọn link Google trong Blogspot
4/ 5
Oleh
Open Comments
Close comment

8 comments

  1. This comment has been removed by the author.

    ReplyDelete
  2. This comment has been removed by the author.

    ReplyDelete
  3. Càm ơn bạn. bạn có thể chụp lại cho mình xem với được không? Bạn nhớ thẻ Script nằm dưới thẻ đóng Style
    nhé!

    ReplyDelete
    Replies
    1. This comment has been removed by the author.

      Delete
    2. Hì. không có gì đâu bạn.

      Delete
  4. Hello Everyone This blog Providing Awesome idea about Link Shortening I have seen most of people not getting proper information, I have seen some of website but I feel tinycc.com is best one for Link Shortening.

    ReplyDelete
  5. Goo.gl sắp bị đóng hoàn toàn rùi ad, em xài Shortener.cc khá ok a.

    ReplyDelete