You have it easy, since the M8 has an unlockable bootloader.
What you'll want to do is:
1) Unlock your bootloader
2) Download and flash the TWRP build for your device.
3) Boot into recovery (TWRP)
4) Download the supersu zip onto your phone from http://forum.xda-developers.com/showthread.php?t=1538053
5) Flash it, and you're rooted.
If you help need doing the above: http://htc-one.wonderhowto.com/how-to/unlock-bootloader-root-your-htc-one-m8-0154444/
As for a Marshmallow ROM, stop at step 2 above. Then grab the latest (as of Apr. 4, 2016) build of Cyanogen Mod for the M8 from here.
How to install it:
1) Copy that ROM onto your phone
2) Boot into recovery (TWRP)
3) Select Wipe > Factory Reset (A "dirty flash" isn't recommended)
4) Then, on the main TWRP screen, select Install, and point it to the ROM file you copied to your device.
5) Swipe to flash
6) Welcome to the world of ROMing & rooting!