Making a table of contents in WordPress

One specific issue I have had with WordPress is that it is sometimes really difficult to choose how to implement a certain content element on the site.

A good example is a table of contents.

There are so many options on how to do it:

  • Use a plugin
  • Use a Gutenberg block
  • Make it manually on each page
  • Implement it hardcoded with PHP
  • Build something in functions.php that you can call

You could also choose a theme where this comes as a built-in option.

The problem is that when I am designing the features of my site, depending on the previous dependencies (like my choice of theme), building something like this might be prohibitively expensive or cost next to nothing.

If I choose the wrong option, my site speed will go down significantly.

The way I think I will do this is that I will just bolt on all of the functionality I need. I think of this like building an electric car prototype with store picked parts.

Then, after the site has gained traction, I will flatten all this down to increase site speed. Basically, using purpose-built components.

Leave a comment