Creating and Using Website Template

I’m working on a template page to use for my website. The template is very specific to my page and consists of:

  • A div for a 3D graphic
  • A div for associated text
  • Buttons to change the graphics and text (there are several stages of graphics and associated text and the buttons would move through the stages)

I just want to see if my approach toward creating and using a template is reasonable:

I plan to put the template in a module. It would consist of CSS for styling the divs and a JavaScript class. The class would have graphics and texts as properties which could be modified. It would also have methods for constructing the divs and putting the text, graphics, and buttons in.

I would then write files for each page which would import the module, create the graphics, have the text I want to include, and call the methods.

Is the proper way of creating and using a template? Thank you in advance for any advice!