Zend certified PHP/Magento developer

Add Product Category To Page Tile As Data Attribute

I am brand new to Magento and am a WordPress developer and am trying to get my bearings on something that seems like it should be simple to accomplish. I am trying to simply add a data-attribute to my product title on the product details page. I want to do this so I can add some logic in my JS based on it. The issue is despite the research I have done I cannot get it to work.

I have located the title.phtml file and tried adding in

data-category="< ?php echo $block->getCurrentCategory->getId() ?>"

but when I reload the page it is just white.

What is the easiest way to go about this? In wordpress I can literally just do the_title() and it gets the title of the post. Is there something similar by chance?