On single page and post templates the main loop is only ever going to contain one post, so you don’t need to worry about duplicate IDs in your example.
On single page and post templates the main loop is only ever going to contain one post, so you don’t need to worry about duplicate IDs in your example.