: Convenient practice for where to place images? 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,
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.
More posts by @Fox8124981
3 Comments
Sorted by latest first Latest Oldest Best
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.
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 : 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 :)
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.
Terms of Use Create Support ticket Your support tickets Stock Market News! © vmapp.org2024 All Rights reserved.