How Custom URL Shortener Works?
We volition locomote using a script to exercise our ain URL shortening service. This script tin besides locomote termed equally "Simple Redirects". Just similar WordPress, y'all exercise links that volition redirect y'all to external pages or domains. Unlike Blogger Custom Redirects, which does non allows y'all to redirect to other domains, they alone redirects to internal pages of your blog.Default URL: www.facebook.com/mybloggerlab
Custom Branded Short URL: www.mybloggerlab.com/go/fb
Take a expect at the higher upward links to empathise how this script volition work. If y'all volition become to www.mybloggerlab.com/go/fb it volition accept y'all to the Facebook page of MyBloggerLab. Similarly y'all tin exercise unlimited brusk URLs as well as Redirects using this script.
How to Make Your Own URL Shortener amongst JavaScript:
To install URL Shortener script inward your Blogger site, delight follow the below instructions correctly:
- Go to Blogger >> Template >> Edit HTML.
- Now inward the template codes, search for </head> tag as well as only higher upward it glue the next JavaScript code:
<script language='javascript'>
//MyBloggerLab URL Shorener
//<![CDATA[
var primal = window.location.href.split("go/")[1].replace("/","")
var urls={
'fb':'https://www.facebook.com/mybloggerlab',
'gplus':"https://plus.google.com/+mybloggerlab",
'twitter':"https://twitter.com/mybloggerlab",
}
if(key){
if(urls[key]){
window.location.href=urls[key]
}else{
document.write("'"+key+"' non institute :(");
}
}
//]]>
</script>
Customization:
Now to exercise brusk URLs y'all tin uncomplicated build changes to the higher upward code. For example, inward the higher upward code search for this:
'fb':'https://www.facebook.com/mybloggerlab',
In the higher upward code fb is the keyword as well as https://www.facebook.com/mybloggerlab is the targeted website or webpage. If nosotros translated the higher upward code it agency that when you'll watch www.mybloggerlab.com/go/fb it volition accept y'all to https://www.facebook.com/mybloggerlab.
You tin add together to a greater extent than brusk URLs equally well, for instance if y'all desire to exercise a brusk link for y'all Pinterest profile as well as therefore the higher upward code volition expect similar this:
<script language='javascript'>
//MyBloggerLab URL Shorener
//<![CDATA[
var primal = window.location.href.split("go/")[1].replace("/","")
var urls={
'fb':'https://www.facebook.com/mybloggerlab',
'gplus':"https://plus.google.com/+mybloggerlab",
'twitter':"https://twitter.com/mybloggerlab",
'pinterest':"https://twitter.com/mybloggerlab",
}
if(key){
if(urls[key]){
window.location.href=urls[key]
}else{
document.write("'"+key+"' non institute :(");
}
}
//]]>
</script>
3. After customizing the script equally per your needs, press the "Save Template" push on the meridian of your screen.
We promise this tutorial has helped y'all inward learning how to build your ain URL shortener inward Blogger. Let us know what are y'all thoughts inward the comments below.
No comments:
Post a Comment