     if opts.history_aware_links
       install_history_aware_links()
 
-    opts.root ||= '/'
-    if opts.root[0] != '/'
-      opts.root = '/' + opts.root
-    Earl.root = opts.root
+    Earl.root = '/'
+    if window.location.pathname.match('.html')
+      Earl.root += location.pathname.match(/\/(\w+\.html)/)[1] + '/'   
 
     # Earl, don't forget to update us if the browser back or forward button pressed
     window.addEventListener 'popstate', (ev) -> 

#   Earl.start_work
#     opts: 
#        history_aware_links: Enables history aware link. Wraps basic dom.A. [false]
#        root: the base path that urls are relative too, such as my_root.html. ['/']
#   Earl.load_page
#     Convenience method for changing the page's url



      # update browser history if it hasn't already been updated
      if url_from_browser_location() != new_location
        h = (Earl.root + new_location)
        history.pushState loc.query_params, title, h.replace(/(\/){2,}/, '/').replace(/(\/)$/, '')

      @last_location = new_location

