From af949d1a8a1141820f5a9bde47b6d3e3e8c99f12 Mon Sep 17 00:00:00 2001 From: lucperkins Date: Wed, 20 Jun 2018 15:55:16 -0700 Subject: [PATCH] Auto _headers file generation logic --- config.toml | 15 ++++++++++++++- .../index.headers | 2 +- netlify.toml | 3 +-- 3 files changed, 16 insertions(+), 4 deletions(-) rename netlify_noindex_headers.txt => layouts/index.headers (60%) diff --git a/config.toml b/config.toml index 08ad4bff74b97..70833bdbb9de4 100644 --- a/config.toml +++ b/config.toml @@ -31,14 +31,27 @@ date = ["date", ":filename", "publishDate", "lastmod"] # Be explicit about the output formats. We (currently) only want an RSS feed for the home page. [outputs] -home = [ "HTML", "RSS"] +home = [ "HTML", "RSS", "HEADERS" ] page = [ "HTML"] section = [ "HTML"] +# Add a "text/netlify" media type for auto-generating the _headers file +[mediaTypes] +[mediaTypes."text/netlify"] +suffix = "" +delimiter = "" + [outputFormats] [outputFormats.RSS] baseName = "feed" +# _headers file output (uses the template at layouts/index.headers) +[outputFormats.HEADERS] +mediatype = "text/netlify" +baseName = "_headers" +isPlainText = true +notAlternative = true + [params] time_format_blog = "Monday, January 02, 2006" diff --git a/netlify_noindex_headers.txt b/layouts/index.headers similarity index 60% rename from netlify_noindex_headers.txt rename to layouts/index.headers index c45a1be4250c0..221563cc13fe8 100644 --- a/netlify_noindex_headers.txt +++ b/layouts/index.headers @@ -1,3 +1,3 @@ # Prevent bots from indexing site /* - X-Robots-Tag: noindex + X-Robots-Tag: noindex \ No newline at end of file diff --git a/netlify.toml b/netlify.toml index 904f6956c9b0f..13704d0eb274a 100644 --- a/netlify.toml +++ b/netlify.toml @@ -1,7 +1,6 @@ [build] -# This default build command adds the robots noindex directive to the site headers publish = "public" -command = "hugo && cp netlify_noindex_headers.txt public/_headers" +command = "hugo" [context.production.environment] HUGO_BASEURL = "https://kubernetes.io/"