You can add HTML meta tags to every page in an MDriven Turnkey application by placing an override file in your application's AssetsTK folder.
Add extra meta tags
Turnkey looks for the following file in the AssetsTK strategy folder:
<YourModelFileName>_AssetsTK/Views/EXT_OverridePages/__ExtraMetaTags.cshtml
For example, if your model file is named MyApplication, create:
MyApplication_AssetsTK/Views/EXT_OverridePages/__ExtraMetaTags.cshtml
When Turnkey finds this file, it reads its contents and injects them after the standard meta tags in the generated page.
Procedure
- Locate the
<YourModelFileName>_AssetsTKfolder used by your Turnkey application. - Create the folder structure
Views/EXT_OverridePagesif it does not already exist. - Create a file named
__ExtraMetaTags.cshtmlin that folder. - Add the meta tag or tags you want Turnkey to include.
- Deploy or otherwise make the AssetsTK file available with the application according to your AssetsTK strategy.
- Load a Turnkey page and inspect the generated HTML
<head>to verify that the tags occur after Turnkey's standard meta tags.
Examples
Ask robots not to index pages
Add the following to __ExtraMetaTags.cshtml to request that robots do not index the page:
<meta name="robots" content="noindex">
Set a Content Security Policy
A Content Security Policy (CSP) controls which sources the browser may use for page resources. For example, this policy permits content only from the same origin:
<meta http-equiv="Content-Security-Policy" content="default-src 'self'">
This policy also blocks inline scripts and inline styles. Blocking inline scripts can be acceptable because standard Turnkey does not depend on them. Blocking inline styles is more disruptive: Bootstrap and AngularJS need to change styles dynamically through DOM manipulation.
If Turnkey pages need inline styles, use a policy that explicitly allows them while keeping the default source restricted to the same origin:
<meta http-equiv="Content-Security-Policy" content="style-src 'unsafe-inline' 'self'; default-src 'self'">
| Meta tag | Result |
|---|---|
<meta name="robots" content="noindex">
|
Requests that robots do not index the page. |
default-src 'self'
|
Restricts default resource loading to the same origin and blocks inline scripts and styles. |
style-src 'unsafe-inline' 'self'; default-src 'self'
|
Restricts default resource loading to the same origin while permitting inline styles required by Bootstrap and AngularJS behavior. |
Content Security Policy considerations
Test a CSP against the full Turnkey user interface before using it in production. A policy that is too restrictive can prevent the browser from applying dynamically changed styles and can break the visual behavior of the application.
Keep the override focused on tags intended for the HTML document head. For UI-specific markup and presentation changes, use the appropriate Turnkey override mechanism instead; TagExpander is documented for ViewModel-oriented UI expansion.
