Targets GDS Frontend v4.1.0
Install the GovUk.Frontend.AspNetCore NuGet package:
Install-Package GovUk.Frontend.AspNetCore
Or via the .NET Core command line interface:
dotnet add package GovUk.Frontend.AspNetCore
Add services to your application's Startup
class:
using GovUk.Frontend.AspNetCore;
public class Startup
{
public void ConfigureServices(IServiceCollection services)
{
services.AddGovUkFrontend();
}
}
This will register a Tag Helper Component that automatically adds stylesheet and script imports to your Razor views.
If you do not want this then use the overload of AddGovUkFrontend
that takes an Action<GovUkFrontendAspNetCoreOptions>
argument and set AddImportsToHtml
to false
:
services.AddGovUkFrontend(options =>
{
options.AddImportsToHtml = false;
});
In your _ViewImports.cshtml
file:
@addTagHelper *, GovUk.Frontend.AspNetCore
This package serves the GDS Frontend assets (stylesheets, javascript, fonts) inside the host application so these do not need to be imported separately.