Try below steps
Step:1 Create default.xml
at location app\code\<Vendor-Name>\<Module-Name>\view\frontend\layout
and add below code
<referenceContainer name="page.top">
<block class="Magento\Framework\View\Element\Template" name="custom-block-name" template="<Vendor-Name>_<Module-Name>::page\custom.phtml"/>
</referenceContainer>
OR
<referenceContainer name="main.content">
<block class="Magento\Framework\View\Element\Template" name="custom-block-name" template="<Vendor-Name>_<Module-Name>::page\custom.phtml"/>
</referenceContainer>
Step:2 Create custom.phtml
at location app\code\<Vendor-Name>\<Module-Name>\view\frontend\templates\page\
and add your code
for eg.
<?php
echo "Custom Block";
?>
Step:3 After run compile command
php bin/magento setup:di:compile