Take the 2-minute tour ×
Webmasters Stack Exchange is a question and answer site for pro webmasters. It's 100% free, no registration required.

A lot of developers place all image files inside a central directory, for example:

/i/img/
/images/
/img/

Isn't it better (e.g. content architecture, on-page SEO, code maintainability, filename maintainability, etc.) to place them inside the relevant directories in which they are used?

For example:

example.com/logo.jpg
example.com/about/photo-of-me.jpg
example.com/contact/map.png
example.com/products/category1-square.png
example.com/products/category2-square.png
example.com/products/category1/product1-thumb.jpg
example.com/products/category1/product2-thumb.jpg
example.com/products/category1/product1/product1-large.jpg
example.com/products/category1/product1/product2-large.jpg
example.com/products/category1/product1/product3-large.jpg

What is the best practice here regarding all possible considerations (for static non-CMS websites)?


N.B. The names product1-large and product1-thumb are just examples in this context to illustrate what kind of images they are. It is advised to use descriptive filenames for SEO benefit.

share|improve this question
    
Frameworks such as Zend often have features which if you store images in a single folder say /public/images or img I forget it's easier to use through out the code. If you can imagine writing a programming having to remember which folder your image is in category1 or category2 it would be a headache. What about products which belong in two categories. Then what do you do? It's just a matter of working efficiently. –  Anagio Dec 17 '12 at 5:29

3 Answers 3

up vote 2 down vote accepted

I personally use a bit of both... I place all the images with a general purposes (things like : design, icons, site content, sprites, etc..) in a single directory.

Then for everything related to a single "thing" on my website, by example a .jpg avatar related to a single user, I put that in a specific directory but inside of a centralized structure.. something like this :

/data/users/1/avatar.jpg
/data/users/2/avatar.jpg
/data/articles/1/main_picture.jpg

At first there is the data directory, it's a good idea to have a main directory like that because when comes the time where you want to do urlRewriting like that : http://mywebsite.com/users/1/, that will confuse everything as the directory already exists on the server root... so putting everything in a centralized directory prevents that.

Also note that I don't use product's name or category's name in the sub-directories, I prefer to use IDs as it's more optimized and simple to use.

I can't prove this is the best structures considering SEO, but it's the best structure that I've experienced and I can say it's the most extensible because everything is placed in a logical way in a point of view of object oriented programming. If you want to add a personalized profile song for every site's users, fine ! You already have the structure right there, no need to add a new directory called songs/ and etc...

And based on that structure, nothing prevents you from using some kind of urlRewriting to have URLs with the products/categories name in it, and then point to the IDs based structure on your server, that would be perfect I guess, but I've never tried...

Hope it helps :)

share|improve this answer

The location of images has no effect on your rankings, it will use the URL of the page and not that of the server, otherwise those with Content Delivery Networks wouldn't use content delivery networks.

The file name however does help a little. So rather than having product1-large.jpg

You should use something like this:

<img src="http://www.example.com/images/ipod-nano-pink.jpg" alt="Ipod Nano in Pink">

Personally unless you have 10,000's of pictures theres no reason why you can't slam them all in one folder. If you do have this many then I'd use something sort as possible so the HTML code is short.

For example

<img src="http://www.example.com/i/apple/ipod-nano-pink-lg.jpg" alt="ipod nano in pink">
<img src="http://www.example.com/i/apple/ipod-nano-pink-sm.jpg" alt="ipod nano in pink">
<img src="http://www.example.com/i/microsoft/xbox360-lg.jpg" alt="xbox 360">
<img src="http://www.example.com/i/microsoft/xbox360-sm.jpg" alt="xbox 360">

Just because your site is static doesn't mean that the pictures need to be in the same path.

Just use the full path as shown in my examples or if you want to use shortcode if you have:

example.com/page1/page2/

you would use

 ../../i/microsoft/xbox360-sm.jpg

Personally I find it easier just to use the absolute paths.

share|improve this answer
1  
I wouldn't say it has "no effect" unless I had data, but I understand where you are coming from. I'd like to avoid an SEO debate, but you may find this answer interesting. The product1-large.jpg was just an example for the sake of keeping the example short, but good that you picked up on it! –  Baumr Dec 17 '12 at 0:49
    
It has no effect due to the climb in CDN networks, and people using CMS systems that do not store images in the same path as that of the URL path. Anyone trying to debate this would be thinking non logical. ;) It could help Google imaging rankings I guess on credibility, but I seriously doubt that. –  bybe Dec 17 '12 at 0:51
    
Furthermore in this topic and not swinging in the SEO route. Google uses the page content, and ALT tag to verify the credibility of the image, while the location of the file could be a factor it, there are so many other factors that I doubt its even required. –  bybe Dec 17 '12 at 0:55

If you are looking at images for SEO benefit, then forget about where to put them in your directory structure. Better look at creating an image sitemap and submit it to Google Webmaster for indexing.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.