In trying to get vim to indent .html files properly, I followed the examples set out here.
Given the following file index.html
The first troubleshooting step is to run :scriptnames. If you don't see .../indent/html.vim, then that means the plugin is not loaded correctly and indenting won't work properly. It will probably just left indent every line. (The problem is that vim doesn't give an error, so it seems like the indenting is doing an awful job.)
The most reliable way to get it working is to put this line in your ~/.vimrc.
filetype plugin indent on
Then open the file with vim again, and run :scriptnames. You should see .../indent/html.vim now. Then type gg=G to autoformat the entire file.
One important note that tripped me up for a while: If you don't put it in ~/.vimrc and just type :filetype plugin indent on after you've opened the file, you will have to re-open the file again with :e. The indent plugin has to be loaded before you open the file. Run :scriptnames to confirm.
Side note: you don't need to worry about smartindent or autoindent settings, those are for something else.