Actually i am trying to add fonts path in default_head_blocks.xml file magento 2 custom theme.

I added fonts files in app/design/vendor/theme/web/fonts. I am trying to get this path.

2 Answers 2


You can add path of custom fonts in _typography.less of your custom theme which located at app/design/vendor/theme/web/source/_typography.less file like below:

@font-face {
   font-family: 'Roboto';
   src: url('@{baseDir}fonts/roboto.woff2') format('woff2'),
   url('@{baseDir}fonts/roboto.woff') format('woff');
   font-weight: normal;
   font-style: normal;    

Note: Add your font files in app/design/vendor/theme/web/fonts directory.

And you can assign this font in default font variable like below:

@font-family-name__base: 'Roboto';

Just follow this steps from the official DevDocs https://devdocs.magento.com/guides/v2.3/frontend-dev-guide/layouts/xml-manage.html#layout_markup_css

Plus you also need to do what Dipesh Rangani said on the previous answer. Both steps are needed.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.