Skip to content

Instantly share code, notes, and snippets.

@mkorostoff
Last active November 3, 2015 15:49
Show Gist options
  • Save mkorostoff/d623201067250714091b to your computer and use it in GitHub Desktop.
Save mkorostoff/d623201067250714091b to your computer and use it in GitHub Desktop.
<!DOCTYPE html>
<html{{ html_attributes }}>
<head>
{{ page.head }}
<title>{{ head_title }}</title>
{{ page.styles }}
<link href='http://fonts.googleapis.com/css?family=Open+Sans' rel='stylesheet' type='text/css'>
{{ page.scripts }}
</head>
<body{{ attributes }}>
<a href="#main-content" class="visually-hidden focusable skip-link">
{{ 'Skip to main content'|t }}
</a>
{{ page_top }}
{{ page.content }}
{{ page_bottom }}
{{ page.scripts('footer') }}
</body>
</html>
@jfcartier
Copy link

Well this works but it's not recommended. Here's a better way.

/**
 *  Implements hook_page_attachments_alter().
 */
function MYMODULE_page_attachments_alter(array &$page)
{
    $page['#attached']['css'][] = array(
        'type' => 'external',
        'data' => '//fonts.googleapis.com/css?family=Roboto',
        'every_page' => TRUE,
    );
}

@lewisnyman
Copy link

You can do this by adding one line to a library:

https://fonts.googleapis.com/css?family=Ubuntu:400,300,700,500,400italic: { type: external, minified: true }

See: https://www.drupal.org/theme-guide/8/assets#external

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment