How to add shortcode to blogspot?
Asked Answered
G

2

6

Is it possible to create shortcodes in blogger? Something like:

[item]contents[/item] 

or

[img class='someClass']yourimagelink[/img]
Glisson answered 26/2, 2015 at 3:37 Comment(2)
youtube.com/watch?v=aUndjBROwSM&feature=youtu.bePierson
Thanks. Ive already seen that but it doesn't seem to be helpful :)Glisson
P
1

The short answer is: it depends

  • for pieces that augment features of content present on the page, or if you don't care about SEO and are convinced that [img src=a class=b] is better than <img src="a" class="b">, yes, it's possible eg see Blogger shortcode plugin or create your own with shortcode.js.
  • for important pieces of content that should be indexed no, it's not possible.

If you're interested in why, here's the long answer:

To access a webpage, you have servers and their pre-[browser-load]-processing languages (PHP, ASP, Ruby, Perl..), and clients (browsers) with their languages (Java-, Type-, & Actionscript). Search engines rely on code sent by the server evidently because only humans need a browser to query a page. As with many free hosts (freewebs, wix, ..), you do not have direct access to the server-side code in Blogger, but you can modify the XHTML-like template with custom tags like Blogger's <b:include>, which behind the scenes probably makes a call to <?php include() ?> or similar. This leaves us client-side scripting as only alternative.

While the shortcode blogger plugin mimics the Wordpress shortcodes, it is built in Javascript and therefore of no use to [traditional] search engines.

Reportedly, Google could access some Javascript contents by using the Chrome browser as an extension of its search engine (so it is rumored). However, the page linked to shows mixed success results. It's not because you can understand some words in a song that you can necessarily make sense of it: even if search engines index it, they won't necessarily do it correctly. It also begs the question: if 90% of your visitors access the website from another browser, how will Google get enough data to make sense of your dynamic content?

If you have a look at the Blogger shortcode plugin, you will also notice that what it enables are basic CSS-styled elements, and third-party embeds, which you can usually copy-paste an embed-code from to your page in HTML view. And as a personal note, I would say: why use shortcodes like [image class=x] when that's exactly the same as doing <img class="x">?

Conclusion: don't use shortcodes and stay on Blogger, or get hosting with a CMS that natively supports shortcodes like Wordpress.

Parapet answered 20/4, 2015 at 17:31 Comment(0)
W
0

My Blogger Tricks has recently created a bunch of shortcodes for blogger. You can check them out here.

To create your own shortcodes

You can create shortcodes for your site with shortcode.js Here is how you will create an [item]contents[/item] shortcode. Run the code to see it in action.

new Shortcode(document.querySelector('body'), {
  item: function(done) {
    return this.contents;
  }
});
<script src="https://rawgit.com/nicinabox/shortcode.js/master/src/Shortcode.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
[item]Sample text[item]
Weigand answered 20/4, 2015 at 13:24 Comment(4)
While this might seem convenient, keep in mind that any JS dynamically inserted content will not be crawled by search engines if it is not on the page on initial load. That makes this solution suitable only for small, unimportant pieces of content.Parapet
what if we call this script on page load,will it be indexed?Weigand
may be this would help someone-downloads.mybloggertricks.com/shortcodes.jsWeigand
Upon some research I found that google does index dynamically inserted content now-moz.com/ugc/…Weigand

© 2022 - 2024 — McMap. All rights reserved.