Get URL in the .phtml template files

1. Get URL of the store homepage (http://domain.com/):

<?= $this->getUrl() ?>

2. Get URL of some page, e.g. "Contact Us" (http://domain.com/contacts/):

<?= $this->getUrl('contacts') ?>

3. Get URL of the theme static file, e.g.:

app/design/frontend/ThemeVendor/theme_name/web/css/custom.css
app/design/frontend/ThemeVendor/theme_name/Magefan_Blog/web/js/lazyload.js
app/code/Magefan_Blog/view/frontend/web/js/lazyload.js
vendor/magefan/module-blog/view/frontend/web/js/lazyload.js

use the following code:

<?= $this->getViewFileUrl('css/custom.css') ?>
<?= $this->getViewFileUrl('Magefan_Blog::js/lazyload.js') ?>

4. Get URL of the static file in pub/media:

$objectManager = \Magento\Framework\App\ObjectManager::getInstance();
$mediaUrl = $objectManager->get(Magento\Store\Model\StoreManagerInterface::class)
->getStore() ->getBaseUrl(\Magento\Framework\UrlInterface::URL_TYPE_MEDIA);
<?= $mediaUrl ?>wysiwyg/image.png

Attention! You should not use media files in the theme or use Object Manager.

Get URL in the WYSIWYG editor

1. Get URL of the store homepage:

{{store url=''}}

2. Get URL of some other page, e.g. "Contact Us" (http://domain.com/contacts/):

{{store url='contacts'}}

3. Get URL of the theme static file:

{{view url='css/custom.css'}}
{{view url='Magefan_Blog::js/lazyload.js'}}

4. Get the URL of the static file in pub/media:

{{media url="wysiwyg/image.png"}}