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

Just wondering if it makes any difference to Google whether or not I URL encode the image names when linking to them.

For example if I have an image named "test-1234-!.jpg", does it make a difference if I name it refer to it as "test-1234-%21.jpg"?

The reason I am asking is because I am doing a major shift in the way my website works and while all new image names will not be URL encoded, all of the past ones are. I want to see if it is worth it renaming all of them or if I should just leave it like that.

share|improve this question
1  
This is "URL encoding", rather than "HTML encoding". Presumably when you say "renaming all of them", you don't literally mean "renaming the file", but the "URL in the HTML document"? –  w3d Oct 17 '12 at 16:38
    
Yes sorry, I meant URL encoding. And yes I mean the URL pointing to the image itself. –  TheGateKeeper Oct 17 '12 at 16:41
add comment

1 Answer 1

up vote 2 down vote accepted

See RFC 3986 - Uniform Resource Identifier (URI): Generic Syntax about the gory details of Url encoding. You should always urlencode your references, keep things standard conform and this way don't break your clients requests.

Google Bot will be happy if it can fetch all your linked assets and this is what you want. Of course the bot is able to url-decode your references/links.

Don't be tricked that it looks some sites do not urlencode: Almost everytime the browser already decoded a urlencoded link just for user readability (e.g. in the address bar). If you look at the source you'll notice the truth.

share|improve this answer
    
I have URL encoded all of my image reference. What exactly is the benefit of doing this and what are the downsides of not doing it? –  TheGateKeeper Oct 18 '12 at 6:25
1  
It's not just relevant for images, it's always relevant if you want standard conform URIs. The benefit is at a minimum that everything can be crawled, requested or displayed as expected. See also this discussion stackoverflow.com/questions/912811/… –  initall Oct 18 '12 at 8:16
    
I see. I have URL encoded most of the dynamic elements on my website but left the static ones as they were, given that they are indeed static and thus will never change into an invalid URI. –  TheGateKeeper Oct 18 '12 at 10:29
    
Just thinking... "the bot ... url-decode your references/links" - but does the bot decode the encoded links? The browser does not necessarily decode the links. I think this might depend on which characters are encoded and whether they belong to the reserved set. Reserved characters (of which ! is one) should not be decoded by the browser and is sent to the server as is - the server then decodes the URL. eg. Google Chrome treats "test-1234-!.jpg" and "test-1234-%21.jpg" as 2 separate URLs, both are sent as is to the server as 2 separate requests and both are cached separately. –  w3d Oct 18 '12 at 11:55
    
cont... conversely "test.jpg" and "%74%65%73%74.jpg" (unreserved characters are encoded - not recommended) are treated the same by the Browser (Chrome). The browser does indeed decode the encoded URL and sends only a single request. Both these cases are according to the spec (RFC 3986 as linked to above), but the spec also states that some systems might incorrectly treat all encoded/decoded URLs as different. The moral of the story is to be consistent in your encoding. –  w3d Oct 18 '12 at 12:00
show 1 more comment

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.