Install using precompiled files
You can install GOV.UK Frontend by copying our CSS, JavaScript and asset files into your project. If you install this way, you can try GOV.UK Frontend in your application without having to make many changes.
What you cannot do after installing
You’ll not be able to:
- change Sass settings, for example override colours or set your own font
- use the Nunjucks code from the Design System website to add components
- import an individual component’s CSS or JavaScript
- use GOV.UK Frontend’s colours or mixins in your custom code
Copy the files
- Download the
release-<VERSION-NUMBER>.zip
file at the bottom of the latest GOV.UK Frontend release note. - Unzip the zip file.
- Copy the
assets
folder to the root of your project’s public folder, so that for example<YOUR-SITE-URL>/assets/govuk-logotype-crown.png
shows thegovuk-logotype-crown.png
image in your users’ browsers. - Copy the 2
.css
files to a stylesheets folder in the root of your project’s public folder, so that for example<YOUR-SITE-URL>/stylesheets/govuk-frontend-<VERSION-NUMBER>.min.css
shows the CSS file in your users’ browsers. - Copy the
.js
file to a JavaScript folder in the root of your project’s public folder, so that for example<YOUR-SITE-URL>/javascript/govuk-frontend-<VERSION-NUMBER>.min.js
shows the JavaScript file in your users’ browsers.
Check an example page
Create a page in your project using the following HTML (in your live application, you should use the Design System page template instead):
<!DOCTYPE html> <html lang="en" class="govuk-template "> <head> <title>Example - GOV.UK</title> <meta name="viewport" content="width=device-width, initial-scale=1, viewport-fit=cover"> <!--[if !IE 8]><!--> <link rel="stylesheet" href="/stylesheets/govuk-frontend-<VERSION-NUMBER>.min.css"> <!--<![endif]--> <!--[if IE 8]> <link rel="stylesheet" href="/stylesheets/govuk-frontend-ie8-<VERSION-NUMBER>.min.css"> <![endif]--> </head> <body class="govuk-template__body "> <script> document.body.className = ((document.body.className) ? document.body.className + ' js-enabled' : 'js-enabled'); </script> <!-- component HTML --> <script src="/javascript/govuk-frontend-<VERSION-NUMBER>.min.js"></script> <script> window.GOVUKFrontend.initAll() </script> </body> </html>
Replace
<VERSION-NUMBER>
so the 3 filenames match the files you copied from GOV.UK Frontend’s GitHub repo.Go to the example accordion component on the Design System website and copy the HTML from the first example.
Replace
<!-- component HTML -->
with the accordion HTML you copied.Run your application - you can check it works the same way as the Design System accordion example by selecting the buttons and checking the accordion ‘shows’ and ‘hides’ sections.
You can now get the full code for page layouts and other components from the Design System website.
If the accordion does not work, you can find out more about how to import GOV.UK Frontend’s CSS and JavaScript.