Do I insert the same code into each page? I have done this and for some reason some of the pages go to eachother, and some don't go back to the home page...etc.
Yes you do. Troubleshoot the links a page at a time. The likely errors are incorrect paths (i.e wrong folder name, file name etc.). Sometimes the file is not in the correct folder.