How To Find If All The Images On Your Website Have Alt Tags

Share this on:
28th day of the epic 100 posts in 100 days challenge

In my last post about working through my website checking it against Google's Webmaster Guidelines I said that I was pretty sure that I was in the habit of adding alt tags to all my images.

And i wondered if there was a tool to check if all your website's images had alt tags. I must admit I didn't look, but what I did do was write one for myself.

You can use it too, but you will need a computer running Linux ( it might work on a mac, i need to check this out)- i use Ubuntu. And your website will need a sitemap.xml file.

It's a bash shell script that uses curl to get the sitemap then for each page in the sitemap it uses curl again to retrieve that web page's contents then uses grep to just return the images without alt tags.

The file outputs a list of all the pages on your website, and if there are any images on that web page that don't have alt tags it lists them under the appropriate page heading.

#!/bin/bash
if [[ $@ ]]; then
   url=$1
else
   url='http://yoursite.co.uk/sitemap.xml'
fi
echo -e "\n"
curl -s $url  2>&1 | sed -n '/<loc>http/p' |  sed 's/<[^>]*//g;  s/>//g; s///g' | awk '{
   print "\n" $url 
   p="curl -s " $url " | grep -o \"<img[^>]*\" | grep -v \"alt=\""
   system(p)
}'
 
echo -e "\n"

So was my confidence in the fact that I had put alt tags in all my images justified? No, it wasn't, my little script found 19 images on 7 pages that I had neglected to provide with alt tags. More search engine optimisation actionable activity to follow.....

Web design Leeds, what do you do?

What has kept this web developer busy today:

3 hours 59 minutes Client websites: updating content, search engine optimisation, checking rankings
1 hour 27 minutes This website: writing blog posts
1 hour 20 minutes Updating data on client's website
1 hour Email
50 minutes New project
26 minutes Entrepreneurs' Mutual Support Network: admin tasks

Total: 9 hours 2 minutes

A reasonable amout of time spent on blog post writing today, mainly because it was very short, but not enough time spent on my new project

Exercise: A short 2 mile run in the rain, i wanted to stop at the beginning but by the end I wanted to keep going! Endorphins.

Tomorrow: I need to limit my time blogging and increase my time on my new project.

Share this on:
Mike Nuttall

Author: Mike Nuttall

Mike has been web designing, programming and building web applications in Leeds for many years. He founded Onsitenow in 2009 and has been helping clients turn business ideas into on-line reality ever since. Mike can be followed on Twitter and has a profile on Google+.