...
https://realfavicongenerator.net/ is your best friend. Whoever maintains it does a good job of keeping abreast of the current best practices for new devices and adjusts it's output accordingly. All you have to do is upload an image of at least 260px X 260px and it will output a folder of specifically sized images you can use. For best results I recommend using an svg so it will scale nicely.
After uploading you will be prompted to choose some options for iOS, Android, Windows, and Safari for Mac. If you plan on using the code generated by realfavicongenerator in a static web page like Kalastatic et. al. then go a head and fill out these options. If, however you are generating favicons for Drupal then you can largely ignore this because we are going to be using php to generate all the link and meta tags which I will get to further down. There is also an option at the bottom of the page to supply a path to where the icons will live. It's recommended that you place them in the root of your site but if you choose you can supply a custom path. Again this only applies if you're using these in a static situation. When it comes to Drupal we will supply a custom path in code.
...