A template begins with validation
A mining node selects valid transactions, usually considering fee rate and ancestor packages while respecting weight, sigop and consensus limits. BIP 22's getblocktemplate lets external mining software receive and submit such work.
Coinbase commits and pays
The first transaction creates no more subsidy than consensus permits and collects included fees. Its data can vary an extra nonce, and its outputs pay the miner or pool. A witness commitment is also placed there for SegWit blocks.
The header is the proof-of-work target
Transactions form a merkle root committed in the 80-byte header beside version, previous hash, time, target and nonce. Changing the nonce, time or coinbase-derived root produces fresh header candidates until one hash is below target.
Pools distinguish shares from blocks
A pool gives miners jobs and accepts shares at an easier target to estimate their work. A share is normally not a Bitcoin block. Newer Stratum V2 work aims to improve transport and let miners participate more directly in transaction selection in relevant modes.