Magento 2 – Adding TypeKit Code to the Head

headmagento2

All I want to do is to add a custom font from TypeKit into my Magento 2 website.

Previously I just used to find /app/design/frontend/XXX/XXX/page/head.phtml and edit that. Simple.

With Magento 2 it seems to be hugely complicated. I keep finding articles like this. Do I really need to create an entire Module just to add 2 lines of basic HTML to the head of a document?

Surely there must be an easier way?

I found this similar question, but I dont get the answer. Where do I create a layout file in my theme? Or is it suggesting I create a whole seperate Module again?

I also found this question, and it looks insane. Am I right in thinking that they are editing 3 seperate files, jsut to add a JS file into head?

Surely this cant be right? Isn't there a head.phtml file I can just edit?

Can someone break this down for me, assume I am an idiot, and explain how I can easily just add 2 lines of TypeKit code to the Head. Many thanks.

Best Answer

There is no need to create extension just to add script in head. You can use following setting from admin.

Login to admin and navigate to following :

UPDATE:

In Magento 2.0, the Miscellaneous Scripts feature was located under the Admin > Stores > Configuration > General > Design > HTML head And find Miscellaneous Scripts

Add Your Typekit/Custom script here in Miscellaneous Scripts textarea and Save Config.


In Magento 2.1, this feature was relocated to the Admin > Content > Design > Configuration Tab. You will then need to select the Scope for which you wish to make the changes. In the Other Settings section, select the HTML Head Tab.

Add Your Typekit/Custom script here in Scripts and Style Sheets textarea and Save Config.

Note: Don't forget to clear cache

Hope it helps you