It can get complicated!
Google looks at over 200 different factors to organise and rank the pages on your website and the algorithms involved are incredibly complicated. However QUICKSPROUT have managed to put together a useful animated infographic explaining the process in simple terms.
Courtesy of: Quick Sprout