How to install MacOS

Note: Updated October 2022: Apple has changed the way you can reinstall MacOS. Via Internet Recovery you can get the latest MacOS or the current version of MacOS on the Mac. 
To get the latest MacOS restart holding down Option + Command + R keys. This is the one we recommend because it has an almost 100% success rate.
To get the version of MacOS on your system, restart holding down Command + R keys. This usually gives you the wrong OS and is not recommended. 
Unfortunately Apple does not have a way to select the version of MacOS you want. To get a specific version, make a USN installer.
Please note Macs earlier than mid 2010-2011 can not use Internet Recovery and require a macOS USB installer.

What format to initialise the new SSD?
From High Sierra, Apple has a new drive format structure. When you upgrade to High Sierra, Apple changes your drive format structure to APFS. High Sierra will only reliably work on a drive formatted as APFS.
If you are installing High Sierra the SSD needs to be in Mac OS Extended (Journaled) for the installer to recognise the SSD. The installer will change the SSD to APFS during the install.

To install Mojave, Catalina, Big Sur, Monterey, Ventura: initialise the SSD as APFS.

To install High Sierra, Sierra, El Capitan, Yosemite and earlier: initialise the drive as Mac OS Extended (Journaled)

How to get the latest macOS on a new SSD?
To reinstall using OS Recovery you need an internet connection, either wireless or ethernet cable. To start up using OS Recovery, start up your Mac and immediately hold down one of these combinations of keys.

Command-⌘-R

Reinstall the latest macOS that was installed on your Mac.  

Option-⌘-R

This will upgrade to the latest OS compatible with your Mac. (recommended)

Shift-Option-⌘-R

Reinstall the macOS that came with your Mac, or the closest version that's still available.  
Instructions if running an OS older than Sierra 10.12.4
Sierra is an important OS, some of the updates in this OS are essential for future OS updates. Apple advises that if your Mac is on Yosemite or El Capitan or earlier and you want to upgrade to High Sierra, then Sierra must be installed first. You can not skip Sierra.
Using your old drive to get a new macOS
Your current hard drive will most likely have a recovery partition. Plug your new SSD into the Mac using a USB-SATA cloning cable. Reboot the Mac holding down keys Command (⌘)-R. This should make the Mac boot from the recovery partition. What should happen is the Mac will build The "macOS Utilities" page giving you the option of installing a new macOS (there are also options to restore from Time Machine and Disk Utility).

Using your Time Machine to get a new macOS
Plug the Time Machine directly into your Mac. Hold down the option key and reboot the Mac. Reboot the Mac holding down keys Command (⌘)-R. This should make the Mac boot from the recovery partition. What should happen is the Mac will build The "macOS Utilities" page giving you the option of installing a new macOS (there are also options to restore from Time Machine and Disk Utility). 
I have an old Mac, can I install the latest macOS? 
Apple does limit upgrading older Macs to the latest OS. Everymac has a good guide where you can see which OS you can install on your Mac.
Maximum Supported macOS
We do not support hacking your Mac to install the latest OS. Apple limit the OS for a reason. Generally the newer OS will run slower on older Macs.   

Options for older Macs
You can install MacOS via original Apple disks. Apple no longer makes MacOS disks, DVD, CD or physical media. All MacOS software is delivered digitally. If you have original software media for an macOS like Snow Leopard you can install that software and then upgrade via the App Store to the current version. Use the current MacOS upgrade guide for more information.
Most of the older OS are available but you need to google search for an Apple page with a link, generally searching in the Appstore will not show older versions of macOS. Upgradea ble does have USB installers for most version of macOS
If you are using Leopard, you need to first buy Snow Leopard OSX 10.6 media from Apple to upgrade the MacOS digitally. You can buy from an Apple Store or calling Apple Support.