Where to learn how to write scripts, scenes, and automations in config and system files instead of using UI editor?

Im newer to HA and Ive been reading and viewing alot of videos regarding setting up and utilizing HA for my automating purposes. My question is where are the articles and sites that have an A-Z tutorial on how to write automations in the system files in YAML? I have coding experience but not in YAML. So far ive been utilizing the UI to create automations and viewing the code there to see what the code looks like but if I want to add variables and setup constants based on current state values I have no idea how I would do that. One idea I had was to change my doorbell light to toggle on and a certain color when my doorbell is rung and then revert it back after 1 minute. I have no idea how to code a previous state to revert it back though. Are there any sites that go over how to code in YAML or do I just need to read through the hundreds of posts to eventually get my answer? Im looking for something that is basic tutorial in coding through YAML for HA. Thanks

The docs

The docs that Nick linked to are the most comprehensive source, but I wouldn’t call them a tutorial… they can be hard to navigate, and the search function is often a let down.
But definitely check out the Templating and Trigger Variables (this is one method to get the previous state)

There’s a list of HA related sites, integrations, public configs, and other resources available at https://www.awesome-ha.com.

I would recommend you look at some of the Public Configurations linked at https://www.awesome-ha.com/ from the prior response. There are lots of good coding examples to be found there as well as literally thousands of additional user repositories. Some are very well documented, other are more basic. Chances are, that chunk of code you can’t figure out is already done by someone else. Search GitHub and learn by others example. You will begin to ‘get it’ the more you put into it.