To do most anything with a website, there is a great deal of code that needs to be written. Some of it is very important, and you should put care into the planning and creation of those components, modules, layouts, and etc. Those pieces, if poorly done, will gather issues like snowflakes and you’ll find yourself constantly shoveling out just to make a little progress.
However, “etc” is also filled with those less-important unnamed things. The code surrounding all those important parts that isn’t so vital to plan out or get honed to a fine edge. It isn’t going to last long, or do much, or in some cases even be run twice. You can cobble together some parts to solve a bug, or repair some data, or find out how many times that one IP address tried to log into your site over a week.
If you need to write some shitty code to solve something, don’t beat yourself up over it. Writing shitty code gets the work done, and the practice will help you to identify the parts you do need to spend some extra time getting right.