Multiple pages in your app are just an illusion. Make one HTML document and put as many of your apps main states (pages, modals, etc) in it. Use CSS to hide and show them.
The idea here is to “statically allocate” as much of the view as possible, because it’s much easier to do that than to dynamically generate a hierarchical DOM and then keep track of what has and has not been generated. For something like a “detail view” of, say, bowties, just use one element and replace its contents every time your user looks at a new bowtie.
Besides, unless you’re building a desktop UI or something, most web apps have a limited number of states and pages anyways.