As I have already told you how to add code box in Blogger, now I will show you how to add an auto alt tag generator for images to your Blogger blog. Seo is very important for any webmaster to rank at good position in search engines. And for getting a good position in search engine, you have to follow all ranking factors.
One of the major ranking factors is proper optimising of images for SEO. Many bloggers are lazy to add an alt tag to images. But if you add alt tags to your blog's images, then you might get tired. But now you will not be tired. Yes, you have heard right. Because I have a code that will add alt tags automatically to your blog images. So, today I am showing you how to add auto alt tag generator for your images to blogger blog.
This script can read the name of the image. Means whenever you upload an image in your blog post then this script read the name of the image and add that as an Alt tag. And this code also replaces hyphens, underscores and plus signs in the image name with spaces, so an image named my-first-image.jpg gets the alt tag "my first image". So, before uploading an image to your blog post, rename it properly. So before you upload an image, rename the file properly. Use small words joined by hyphens, like my-first-image.jpg, and the alt tag will read like a normal sentence.
1. Login to your Blogger dashboard.
2. Then go to Theme and click Edit HTML.
3. Click anywhere inside the code area, then press Ctrl + F to open the search box.
4. Search for <head> and paste the jQuery code just below it.
Note:- If you have already added jquery in your blogger Template, just leave this step and follow next step.
One of the major ranking factors is proper optimising of images for SEO. Many bloggers are lazy to add an alt tag to images. But if you add alt tags to your blog's images, then you might get tired. But now you will not be tired. Yes, you have heard right. Because I have a code that will add alt tags automatically to your blog images. So, today I am showing you how to add auto alt tag generator for your images to blogger blog.
How This Script Works
This script can read the name of the image. Means whenever you upload an image in your blog post then this script read the name of the image and add that as an Alt tag. And this code also replaces hyphens, underscores and plus signs in the image name with spaces, so an image named my-first-image.jpg gets the alt tag "my first image". So, before uploading an image to your blog post, rename it properly. So before you upload an image, rename the file properly. Use small words joined by hyphens, like my-first-image.jpg, and the alt tag will read like a normal sentence.
How To Add Auto Alt Tag Generator For Images To Blogger
1. Login to your Blogger dashboard.
2. Then go to Theme and click Edit HTML.
3. Click anywhere inside the code area, then press Ctrl + F to open the search box.
4. Search for <head> and paste the jQuery code just below it.
<script src='https://code.jquery.com/jquery-3.7.1.min.js' type='text/javascript'></script>
Note:- If you have already added jquery in your blogger Template, just leave this step and follow next step.
5. Now search for </body> and paste the alt tag script just above it.
<script type='text/javascript'>6. Click Save Theme and you are done.
//<![CDATA[
$(document).ready(function() {
$('img').each(function() {
var $img = $(this);
var filename = $img.attr('src');
if (!filename) {
return;
}
filename = filename.split('?')[0];
var start = filename.lastIndexOf('/') + 1;
var end = filename.lastIndexOf('.');
if (end <= start) {
end = filename.length;
}
var altText = filename.substring(start, end).replace(/[-_+]/g, ' ');
$img.attr('title', altText);
$img.attr('alt', altText);
});
});
//]]>
</script>
So, this was the easiest way of adding auto alt tag generator for images to blogger. I hope you liked the post. Comment down your problems related to this content and do not forget to share it.


It doesn't work on my website nareja.com? Please advise.
ReplyDeletePlease follow the steps careful and try again. Then comment if it is not working. Thank you.
Delete