Docs: prepare for vercel hosting move (#10598)

* prepare for move to vercel hosting

* update readme

* add back netlify files for hosting transition
This commit is contained in:
Jeff Escalante 2021-01-15 15:29:22 -05:00 committed by GitHub
parent e8164ad09a
commit f48841c6ea
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 1071 additions and 254 deletions

1
website/.env.production Normal file
View File

@ -0,0 +1 @@
HASHI_ENV=production

View File

@ -1,66 +1,74 @@
# Vault Website
[![Netlify
Status](https://img.shields.io/netlify/d72a27d2-aba4-46fd-bf70-d7da0b19b578?style=flat-square)](https://app.netlify.com/sites/vault-www/deploys)
This subdirectory contains the entire source for the [Vault Website](https://vaultproject.io/). This is a [NextJS](https://nextjs.org/) project, which builds a static site from these source files.
This subdirectory contains the entire source for the [Vault
Website](https://vaultproject.io/). This is a [NextJS](https://nextjs.org/)
project, which builds a static site from these source files.
<!--
This readme file contains several blocks of generated text, to make it easier to share common information
across documentation website readmes. To generate these blocks from their source, run `npm run generate:readme`
Any edits to the readme are welcome outside the clearly noted boundaries of the blocks. Alternately, a
block itself can be safely "forked" from the central implementation simply by removing the "BEGIN" and
"END" comments from around it.
-->
## Table of Contents
- [Contributions](#contributions-welcome)
- [Running the Site Locally](#running-the-site-locally)
- [Editing Markdown Content](#editing-markdown-content)
- [Editing Navigation Sidebars](#editing-navigation-sidebars)
- [Changing the Release Version](#changing-the-release-version)
- [Redirects](#redirects)
- [Browser Support](#browser-support)
- [Deployment](#deployment)
<!-- BEGIN: contributions -->
<!-- Generated text, do not edit directly -->
## Contributions Welcome!
If you find a typo or you feel like you can improve the HTML, CSS, or JavaScript,
we welcome contributions. Feel free to open issues or pull requests like any
normal GitHub project, and we'll merge it in 🚀
If you find a typo or you feel like you can improve the HTML, CSS, or JavaScript, we welcome contributions. Feel free to open issues or pull requests like any normal GitHub project, and we'll merge it in 🚀
<!-- END: contributions -->
<!-- BEGIN: local-development -->
<!-- Generated text, do not edit directly -->
## Running the Site Locally
The website can be run locally through node.js or Docker. If you choose to run
through Docker, everything will be a little bit slower due to the additional
overhead, so for frequent contributors it may be worth it to use node. Also if
you are a vim user, it's also worth noting that vim's swapfile usage can cause
issues for the live reload functionality. In order to avoid these issues, make
sure you have run `:set backupcopy=yes` within vim.
The website can be run locally through node.js or [Docker](https://www.docker.com/get-started). If you choose to run through Docker, everything will be a little bit slower due to the additional overhead, so for frequent contributors it may be worth it to use node.
> **Note:** If you are using a text editor that uses a "safe write" save style such as **vim** or **goland**, this can cause issues with the live reload in development. If you turn off safe write, this should solve the problem. In vim, this can be done by running `:set backupcopy=yes`. In goland, search the settings for "safe write" and turn that setting off.
### With Docker
Running the site locally is simple. Provided you have Docker installed, clone
this repo, run `make`, and then visit `http://localhost:3000`.
Running the site locally is simple. Provided you have Docker installed, clone this repo, run `make`, and then visit `http://localhost:3000`.
The docker image is pre-built with all the website dependencies installed, which
is what makes it so quick and simple, but also means if you need to change
dependencies and test the changes within Docker, you'll need a new image. If this
is something you need to do, you can run `make build-image` to generate a local
Docker image with updated dependencies, then `make website-local` to use that
image and preview.
The docker image is pre-built with all the website dependencies installed, which is what makes it so quick and simple, but also means if you need to change dependencies and test the changes within Docker, you'll need a new image. If this is something you need to do, you can run `make build-image` to generate a local Docker image with updated dependencies, then `make website-local` to use that image and preview.
### With Node
If your local development environment has a supported version (v10.0.0+) of [node
installed](https://nodejs.org/en/) you can run:
If your local development environment has a supported version (v10.0.0+) of [node installed](https://nodejs.org/en/) you can run:
- `npm install`
- `npm start`
and then visit `http://localhost:3000`.
...and then visit `http://localhost:3000`.
If you pull down new code from github, you should run `npm install` again.
Otherwise, there's no need to re-run `npm install` each time the site is run, you
can just run `npm start` to get it going.
If you pull down new code from github, you should run `npm install` again. Otherwise, there's no need to re-run `npm install` each time the site is run, you can just run `npm start` to get it going.
## Editing Content
<!-- END: local-development -->
Documentation content is written in
[Markdown](https://www.markdownguide.org/cheat-sheet/) and you'll find all files
listed under the `/pages` directory.
<!-- BEGIN: editing-markdown -->
<!-- Generated text, do not edit directly -->
To create a new page with Markdown, create a file ending in `.mdx` in the
`pages/` directory. The path in the pages directory will be the URL route. For
example, `pages/hello/world.mdx` will be served from the `/hello/world` URL.
## Editing Markdown Content
This file can be standard Markdown and also supports [YAML
frontmatter](https://middlemanapp.com/basics/frontmatter/). YAML frontmatter is
optional, there are defaults for all keys.
Documentation content is written in [Markdown](https://www.markdownguide.org/cheat-sheet/) and you'll find all files listed under the `/content` directory.
To create a new page with Markdown, create a file ending in `.mdx` in a `content/<subdirectory>`. The path in the content directory will be the URL route. For example, `content/docs/hello.mdx` will be served from the `/docs/hello` URL.
This file can be standard Markdown and also supports [YAML frontmatter](https://middlemanapp.com/basics/frontmatter/). YAML frontmatter is optional, there are defaults for all keys.
```yaml
---
@ -72,79 +80,279 @@ description: "A thorough, yet succinct description of the page's contents"
The significant keys in the YAML frontmatter are:
- `title` `(string)` - This is the title of the page that will be set in the HTML
title.
- `description` `(string)` - This is a description of the page that will be set
in the HTML description.
- `title` `(string)` - This is the title of the page that will be set in the HTML title.
- `description` `(string)` - This is a description of the page that will be set in the HTML description.
> ⚠Since `api` is a reserved directory within NextJS, all `/api/**` pages are
> listed under the `/pages/api-docs` path.
> ⚠️ If there is a need for a `/api/*` url on this website, the url will be changed to `/api-docs/*`, as the `api` folder is reserved by next.js.
### Code Highlighting
### Creating New Pages
Code is highlighted using [prism](https://prismjs.com/). Feel free to check out [all the supported languages](https://prismjs.com/#supported-languages) that can be used for code blocks. All code blocks should be tagged with a language as such:
There is currently a small bug with new page creation - if you create a new page and link it up via subnav data while the server is running, it will report an error saying the page was not found. This can be resolved by restarting the server.
````md
```language
// code to be highlighted
```
````
### Markdown Enhancements
If you have a code block that displays a command intended to be run from the terminal, it can be tagged with `shell-session`. This is distinct from `shell` which should represent a shell script. The following example shows a correctly formatted terminal command snippet:
There are several custom markdown plugins that are available by default that enhance [standard markdown](https://commonmark.org/) to fit our use cases. This set of plugins introduces a couple instances of custom syntax, and a couple specific pitfalls that are not present by default with markdown, detailed below:
````md
- If you see the symbols `~>`, `->`, `=>`, or `!>`, these represent [custom alerts](https://github.com/hashicorp/remark-plugins/tree/master/plugins/paragraph-custom-alerts#paragraph-custom-alerts). These render as colored boxes to draw the user's attention to some type of aside.
- If you see `@include '/some/path.mdx'`, this is a [markdown include](https://github.com/hashicorp/remark-plugins/tree/master/plugins/include-markdown#include-markdown-plugin). It's worth noting as well that all includes resolve from `website/content/partials` by default, and that changes to partials will not live-reload the website.
- If you see `# Headline ((#slug))`, this is an example of an [anchor link alias](https://github.com/hashicorp/remark-plugins/tree/je.anchor-link-adjustments/plugins/anchor-links#anchor-link-aliases). It adds an extra permalink to a headline for compatibility and is removed from the output.
- Due to [automatically generated permalinks](https://github.com/hashicorp/remark-plugins/tree/je.anchor-link-adjustments/plugins/anchor-links#anchor-links), any text changes to _headlines_ or _list items that begin with inline code_ can and will break existing permalinks. Be very cautious when changing either of these two text items.
Headlines are fairly self-explanitory, but here's an example of how list items that begin with inline code look.
```markdown
- this is a normal list item
- `this` is a list item that begins with inline code
```
Its worth noting that _only the inline code at the beginning of the list item_ will cause problems if changed. So if you changed the above markup to...
```markdown
- lsdhfhksdjf
- `this` jsdhfkdsjhkdsfjh
```
...while it perhaps would not be an improved user experience, no links would break because of it. The best approach is to **avoid changing headlines and inline code at the start of a list item**. If you must change one of these items, make sure to tag someone from the digital marketing development team on your pull request, they will help to ensure as much compatibility as possible.
### Custom Components
A number of custom [mdx components](https://mdxjs.com/) are available for use within any `.mdx` file. Each one is documented below:
#### Tabs
The `Tabs` component creates tabbed content of any type, but is often used for code examples given in different languages. Here's an example of how it looks from the Vagrant documentation website:
![Tabs Component](https://p176.p0.n0.cdn.getcloudapp.com/items/WnubALZ4/Screen%20Recording%202020-06-11%20at%2006.03%20PM.gif?v=1de81ea720a8cc8ade83ca64fb0b9edd)
It can be used as such within a markdown file:
````mdx
Normal **markdown** content.
<Tabs>
<Tab heading="CLI command">
<!-- Intentionally skipped line.. -->
```shell-session
$ cowsay "hello world"
$ command ...
```
<!-- Intentionally skipped line.. -->
</Tab>
<Tab heading="API call using cURL">
```shell-session
$ curl ...
```
</Tab>
</Tabs>
Contined normal markdown content
````
The intentionally skipped line is a limitation of the mdx parser which is being actively worked on. All tabs must have a heading, and there is no limit to the number of tabs, though it is recommended to go for a maximum of three or four.
#### Enterprise Alert
This component provides a standard way to call out functionality as being present only in the enterprise version of the software. It can be presented in two contexts, inline or standalone. Here's an example of standalone usage from the Consul docs website:
![Enterprise Alert Component - Standalone](https://p176.p0.n0.cdn.getcloudapp.com/items/WnubALp8/Screen%20Shot%202020-06-11%20at%206.06.03%20PM.png?v=d1505b90bdcbde6ed664831a885ea5fb)
The standalone component can be used as such in markdown files:
```mdx
# Page Headline
<EnterpriseAlert />
Continued markdown content...
```
It can also receive custom text contents if you need to change the messaging but wish to retain the style. This will replace the text `This feature is available in all versions of Consul Enterprise.` with whatever you add. For example:
```mdx
# Page Headline
<EnterpriseAlert>
My custom text here, and <a href="#">a link</a>!
</EnterpriseAlert>
Continued markdown content...
```
It's important to note that once you are adding custom content, it must be html and can not be markdown, as demonstrated above with the link.
Now let's look at inline usage, here's an example:
![Enterprise Alert Component - Inline](https://p176.p0.n0.cdn.getcloudapp.com/items/L1upYLEJ/Screen%20Shot%202020-06-11%20at%206.07.50%20PM.png?v=013ba439263de8292befbc851d31dd78)
And here's how it could be used in your markdown document:
```mdx
### Some Enterprise Feature <EnterpriseAlert inline />
Continued markdown content...
```
It's also worth noting that this component will automatically adjust to the correct product colors depending on the context.
#### Other Components
Other custom components can be made available on a per-site basis, the above are the standards. If you have questions about custom components that are not documented here, or have a request for a new custom component, please reach out to @hashicorp/digital-marketing.
### Syntax Highlighting
When using fenced code blocks, the recommendation is to tag the code block with a language so that it can be syntax highlighted. For example:
````
```
// BAD: Code block with no language tag
```
```javascript
// GOOD: Code block with a language tag
```
````
### Editing Sidebars
Check out the [supported languages list](https://prismjs.com/#supported-languages) for the syntax highlighter we use if you want to double check the language name.
The structure of the sidebars are controlled by files in the [`/data`
directory](data).
It is also worth noting specifically that if you are using a code block that is an example of a terminal command, the correct language tag is `shell-session`. For example:
- Edit [this file](data/docs-navigation.js) to change the **docs** sidebar
- Edit [this file](data/api-navigation.js) to change the **api docs** sidebar
🚫**BAD**: Using `shell`, `sh`, `bash`, or `plaintext` to represent a terminal command
To nest sidebar items, you'll want to add a new `category` key/value accompanied
by the appropriate embedded `content` values.
````
```shell
$ terraform apply
```
````
- `category` values will be **directory names** within the `pages` directory
- `content` values will be **file names** within their appropriately nested
directory.
✅**GOOD**: Using `shell-session` to represent a terminal command
### Changing the Release Version
````
```shell-session
$ terraform apply
```
````
To change the version of Vault displayed for download on the website, head over
to `data/version.js` and change the number there. It's important to note that the
version number must match a version that has been released and is live on
`releases.hashicorp.com` -- if it does not, the website will be unable to fetch
links to the binaries and will not compile. So this version number should be
changed _only after a release_.
<!-- END: editing-markdown -->
The `data/version.js` also contains a global variable, `CHANGELOG_URL`, that
should be updated to point to the latest changelog URL for the particular
release version. The URL should be based off the `master` blob such that
it always reflects the most up-to-date changes.
<!-- BEGIN: editing-docs-sidebars -->
<!-- Generated text, do not edit directly -->
## Editing Navigation Sidebars
The structure of the sidebars are controlled by files in the [`/data` directory](data). For example, [this file](data/docs-navigation.js) controls the **docs** sidebar. Within the `data` folder, any file with `-navigation` after it controls the navigation for the given section.
The sidebar uses a simple recursive data structure to represent _files_ and _directories_. A file is represented by a string, and a directory is represented by an object. The sidebar is meant to reflect the structure of the docs within the filesystem while also allowing custom ordering. Let's look at an example. First, here's our example folder structure:
```text
.
├── docs
│   └── directory
│   ├── index.mdx
│   ├── file.mdx
│   ├── another-file.mdx
│   └── nested-directory
│   ├── index.mdx
│   └── nested-file.mdx
```
Here's how this folder structure could be represented as a sidebar navigation, in this example it would be the file `website/data/docs-navigation.js`:
```js
export default {
category: 'directory',
content: [
'file',
'another-file',
{
category: 'nested-directory',
content: ['nested-file'],
},
],
}
```
- `category` values will be **directory names** within the `content/<section>` directory
- `content` values will be **file names** within their appropriately nested directory
A couple more important notes:
- Within this data structure, ordering does not matter, but hierarchy does. So while you could put `file` and `another-file` in any order, or even leave one or both of them out, you could not decide to un-nest the `nested-directory` object without also un-nesting it in the filesystem.
- The `sidebar_title` frontmatter property on each `mdx` page is responsible for displaying the human-readable page name in the navigation.
- _By default_, every directory/category must have an `index.mdx` file. This file will be automatically added to the navigation as "Overview", and its `sidebar_title` property will set the human-readable name of the entire category.
Below we will discuss a couple of more unusual but still helpful patterns.
### Index-less Categories
Sometimes you may want to include a category but not have a need for an index page for the category. This can be accomplished, but a human-readable category name needs to be set manually, since the category name is normally pulled from the `sidebar_title` property of the index page. Here's an example of how an index-less category might look:
```text
.
├── docs
│   └── indexless-category
│   └── file.mdx
```
```js
// website/data/docs-navigation.js
export default {
category: 'indexless-category',
name: 'Indexless Category',
content: ['file'],
}
```
The addition of the `name` property to a category object is all it takes to be able to skip the index file.
### Custom or External Links
Sometimes you may have a need to include a link that is not directly to a file within the docs hierarchy. This can also be supported using a different pattern. For example:
```js
export default {
category: 'directory',
content: [
'file',
'another-file',
{ title: 'Tao of HashiCorp', href: 'https://www.hashicorp.com/tao-of-hashicorp' }
}
]
}
```
If the link provided in the `href` property is external, it will display a small icon indicating this. If it's internal, it will appear the same way as any other direct file link.
<!-- END: editing-docs-sidebars -->
<!-- BEGIN: releases -->
<!-- Generated text, do not edit directly -->
## Changing the Release Version
To change the version displayed for download on the website, head over to `data/version.js` and change the number there. It's important to note that the version number must match a version that has been released and is live on `releases.hashicorp.com` -- if it does not, the website will be unable to fetch links to the binaries and will not compile. So this version number should be changed _only after a release_.
### Displaying a Prerelease
If there is a prerelease of any type that should be displayed on the downloads
page, this can be done by editing `pages/downloads/index.jsx`. By default, the
download component might look something like this:
```jsx
<ProductDownloader product="Vault" version={VERSION} downloads={downloadData} />
```
To add a prerelease, an extra `prerelease` property can be added to the component
as such:
If there is a prerelease of any type that should be displayed on the downloads page, this can be done by editing `pages/downloads/index.jsx`. By default, the download component might look something like this:
```jsx
<ProductDownloader
product="Vault"
product="<Product>"
version={VERSION}
downloads={downloadData}
community="/resources"
/>
```
To add a prerelease, an extra `prerelease` property can be added to the component as such:
```jsx
<ProductDownloader
product="<Product>"
version={VERSION}
downloads={downloadData}
community="/resources"
prerelease={{
type: 'release candidate', // the type of prerelease: beta, release candidate, etc.
name: 'v1.0.0', // the name displayed in text on the website
@ -153,131 +361,46 @@ as such:
/>
```
This configuration would display something like the following text on the
website, emphasis added to the configurable parameters:
This configuration would display something like the following text on the website, emphasis added to the configurable parameters:
```
A {{ release candidate }} for Vault {{ v1.0.0 }} is available! The release can be <a href='https://releases.hashicorp.com/vault/{{ 1.0.0-rc1 }}'>downloaded here</a>.
A {{ release candidate }} for <Product> {{ v1.0.0 }} is available! The release can be <a href='https://releases.hashicorp.com/<product>/{{ 1.0.0-rc1 }}'>downloaded here</a>.
```
You may customize the parameters in any way you'd like. To remove a prerelease
from the website, simply delete the `prerelease` paremeter from the above
component.
You may customize the parameters in any way you'd like. To remove a prerelease from the website, simply delete the `prerelease` paremeter from the above component.
### Markdown Enhancements
<!-- END: releases -->
There are several custom markdown plugins that are available by default that
enhance standard markdown to fit our use cases. This set of plugins introduces a
couple instances of custom syntax, and a couple specific pitfalls that are not
present by default with markdown, detailed below:
<!-- BEGIN: redirects -->
<!-- Generated text, do not edit directly -->
- If you see the symbols `~>`, `->`, `=>`, or `!>`, these represent [custom
alerts](https://github.com/hashicorp/remark-plugins/tree/master/plugins/paragraph-custom-alerts#paragraph-custom-alerts).
These render as colored boxes to draw the user's attention to some type of
aside.
- If you see `@include '/some/path.mdx'`, this is a [markdown
include](https://github.com/hashicorp/remark-plugins/tree/master/plugins/include-markdown#include-markdown-plugin).
It's worth noting as well that all includes resolve from
`website/pages/partials` by default.
## Redirects
> **Note:** Changes to partials will not trigger a hot reload in development
This website structures URLs based on the filesystem layout. This means that if a file is moved, removed, or a folder is re-organized, links will break. If a path change is necessary, it can be mitigated using redirects. It's important to note that redirects should only be used to cover for external links -- if you are moving a path which internal links point to, the internal links should also be adjusted to point to the correct page, rather than relying on a redirect.
- If you see `# Headline ((#slug))`, this is an example of an [anchor link
alias](https://github.com/hashicorp/remark-plugins/tree/je.anchor-link-adjustments/plugins/anchor-links#anchor-link-aliases).
It adds an extra permalink to a headline for compatibility and is removed from
the output.
- Due to [automatically generated
permalinks](https://github.com/hashicorp/remark-plugins/tree/je.anchor-link-adjustments/plugins/anchor-links#anchor-links),
any text changes to _headlines_ or _list items that begin with inline code_ can
and will break existing permalinks. Be very cautious when changing either of
these two text items.
Headlines are fairly self-explanitory, but here's an example of how list items
that begin with inline code look.
```markdown
- this is a normal list item
- `this` is a list item that begins with inline code
```
Its worth noting that _only the inline code at the beginning of the list item_
will cause problems if changed. So if you changed the above markup to...
```markdown
- lsdhfhksdjf
- `this` jsdhfkdsjhkdsfjh
```
...while it perhaps would not be an improved user experience, no links would
break because of it. The best approach is to **avoid changing headlines and
inline code at the start of a list item**. If you must change one of these
items, make sure to tag someone from the digital marketing development team on
your pull request, they will help to ensure as much compatibility as possible.
There are also some custom components available for use within markdown files, see
the links below for more information on usage:
- [Enterprise Alert](components/enterprise-alert/README.md)
- [Tabs](components/tabs/README.md)
### Redirects
This website structures URLs based on the filesystem layout. This means that if a
file is moved, removed, or a folder is re-organized, links will break. If a path
change is necessary, it can be mitigated using redirects.
To add a redirect, head over to the `_redirects` file - the format is fairly
simple. On the left is the current path, and on the right is the path that should
be redirected to. It's important to note that if there are links to a `.html`
version of a page, that must also be explicitly redirected. For example:
To add a redirect, head over to the `redirects.js` file - the format is fairly simple - there's a `source` and a `destination` - fill them both in, indicate that it's a permanent redirect or not using the `permanent` key, and that's it. Let's look at an example:
```
/foo /bar 301!
/foo.html /bar 301!
{
source: '/foo',
destination: '/bar',
permanent: true
}
```
This redirect rule will send all incoming links to `/foo` and `/foo.html` to
`/bar`. For more details on the redirects file format, [check out the docs on
netlify](https://docs.netlify.com/routing/redirects/rewrites-proxies). Note that
it is critical that `301!` is added to every one-to-one redirect - if it is left
off the redirect may not work.
This redirect rule will send all incoming links to `/foo` to `/bar`. For more details on the redirects file format, [check out the docs on vercel](https://vercel.com/docs/configuration#project/redirects). All redirects will work both locally and in production exactly the same way, so feel free to test and verify your redirects locally. In the past testing redirects has required a preview deployment -- this is no longer the case. Please note however that if you add a redirect while the local server is running, you will need to restart it in order to see the effects of the redirect.
There are a couple important caveats with redirects. First, redirects are applied
at the hosting layer, and therefore will not work by default in local dev mode.
To test in local dev mode, you can use [`netlify dev`](https://www.netlify.com/products/dev/), or just push a commit and check
using the deploy preview.
There is still one caveat though: redirects do not apply to client-side navigation. By default, all links in the navigation and docs sidebar will navigate purely on the client side, which makes navigation through the docs significantly faster, especially for those with low-end devices and/or weak internet connections. In the future, we plan to convert all internal links within docs pages to behave this way as well. This means that if there is a link on this website to a given piece of content that has changed locations in some way, we need to also _directly change existing links to the content_. This way, if a user clicks a link that navigates on the client side, or if they hit the url directly and the page renders from the server side, either one will work perfectly.
Second, redirects do not apply to client-side navigation. By default, all links
in the navigation and docs sidebar will navigate purely on the client side, which
makes navigation through the docs significantly faster, especially for those with
low-end devices and/or weak internet connections. In the future, we plan to
convert all internal links within docs pages to behave this way as well. This
means that if there is a link on this website to a given piece of content that
has changed locations in some way, we need to also _directly change existing
links to the content_. This way, if a user clicks a link that navigates on the
client side, or if they hit the url directly and the page renders from the server
side, either one will work perfectly.
Let's look at an example. Say you have a page called `/docs/foo` which needs to be moved to `/docs/nested/foo`. Additionally, this is a page that has been around for a while and we know there are links into `/docs/foo.html` left over from our previous website structure. First, we move the page, then adjust the docs sidenav, in `data/docs-navigation.js`. Find the category the page is in, and move it into the appropriate subcategory. Next, we add to `_redirects` as such. The `.html` version is covered automatically.
Let's look at an example. Say you have a page called `/docs/foo` which needs to
be moved to `/docs/nested/foo`. Additionally, this is a page that has been around
for a while and we know there are links into `/docs/foo.html` left over from our
previous website structure. First, we move the page, then adjust the docs
sidenav, in `data/docs-navigation.js`. Find the category the page is in, and move
it into the appropriate subcategory. Next, we add to `_redirects` as such:
```
/foo /nested/foo 301!
/foo.html /nested/foo 301!
```js
{ source: '/foo', destination: '/nested/foo', permanent: true }
```
Finally, we run a global search for internal links to `/foo`, and make sure to
adjust them to be `/nested/foo` - this is to ensure that client-side navigation
still works correctly. _Adding a redirect alone is not enough_.
Next, we run a global search for internal links to `/foo`, and make sure to adjust them to be `/nested/foo` - this is to ensure that client-side navigation still works correctly. _Adding a redirect alone is not enough_.
One more example - let's say that content is being moved to an external website.
A common example is guides moving to `learn.hashicorp.com`. In this case, we take
all the same steps, except that we need to make a different type of change to the
`docs-navigation` file. If previously the structure looked like:
One more example - let's say that content is being moved to an external website. A common example is guides moving to `learn.hashicorp.com`. In this case, we take all the same steps, except that we need to make a different type of change to the `docs-navigation` file. If previously the structure looked like:
```js
{
@ -288,45 +411,25 @@ all the same steps, except that we need to make a different type of change to th
}
```
If we no longer want the link to be in the side nav, we can simply remove it. If
we do still want the link in the side nav, but pointing to an external
destnation, we need to slightly change the structure as such:
If we no longer want the link to be in the side nav, we can simply remove it. If we do still want the link in the side nav, but pointing to an external destnation, we need to slightly change the structure as such:
```js
{
category: 'docs',
content: [
{ title: 'Foo Title', href: 'https://learn.hashicorp.com/vault/foo' }
{ title: 'Foo Title', href: 'https://learn.hashicorp.com/<product>/foo' }
]
}
```
As the majority of items in the side nav are internal links, the structure makes
it as easy as possible to represent these links. This alternate syntax is the
most concise manner than an external link can be represented. External links can
be used anywhere within the docs sidenav.
As the majority of items in the side nav are internal links, the structure makes it as easy as possible to represent these links. This alternate syntax is the most concise manner than an external link can be represented. External links can be used anywhere within the docs sidenav.
It's also worth noting that it is possible to do glob-based redirects, for
example matching `/docs/*`, and you may see this pattern in the `_redirects`
file. This type of redirect is much higher risk and the behavior is a bit more
nuanced, so if you need to add a glob redirect, please reach out to the website
maintainers and ask about it first.
It's also worth noting that it is possible to do glob-based redirects, for example matching `/docs/*`, and you may see this pattern in the redirects file. This type of redirect is much higher risk and the behavior is a bit more nuanced, so if you need to add a glob redirect, please reach out to the website maintainers and ask about it first.
## Deployment
<!-- END: redirects -->
This website is hosted on Netlify and configured to automatically deploy anytime
you push code to the `stable-website` branch. Any time a pull request is
submitted that changes files within the `website` folder, a deployment preview
will appear in the github checks which can be used to validate the way docs
changes will look live. Deployments from `stable-website` will look and behave
the same way as deployment previews.
## Checking for Broken Links
There is a local script that can be used to check for broken links on the
_current product website_ - you can start it by running `npm run linkcheck`.
There will be a version of this script added as a github check in the near
future!
<!-- BEGIN: browser-support -->
<!-- Generated text, do not edit directly -->
## Browser Support
@ -336,32 +439,13 @@ We support the following browsers targeting roughly the versions specified.
| --------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------ | --------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------- |
| **Latest** | **Latest** | **Latest** | **Latest** | **11+** |
## Known Issues
<!-- END: browser-support -->
### Creating New Pages
<!-- BEGIN: deployment -->
<!-- Generated text, do not edit directly -->
There is currently a small bug with new page creation - if you create a new page
and link it up via subnav data while the server is running, it will report an
error saying the page was not found. This can be resolved by restarting the
server.
## Deployment
### Editing Existing Content
This website is hosted on Vercel and configured to automatically deploy anytime you push code to the `stable-website` branch. Any time a pull request is submitted that changes files within the `website` folder, a deployment preview will appear in the github checks which can be used to validate the way docs changes will look live. Deployments from `stable-website` will look and behave the same way as deployment previews.
There is currently an issue with hot-reload when certain editors, such as GoLand
and Vim, are used to edit content that causes the edited page to fail loading.
This is due to "safe write" behavior in such editors which conflicts with NodeJS'
file watching system.
If you encounter an error similar to the one below, restarting the server will
resolve the issue.
```text
[ error ] ./pages/docs/commands/operator/migrate.mdx
Error: Cannot find module '/website/node_modules/babel-plugin-transform-define/lib/index.js' from '/website'
at Array.map (<anonymous>)
at cachedFunction.next (<anonymous>)
```
Alternately, if you disable safe write by searching goland's settings for "safe
write" or by running `:set backupcopy=yes` in vim, this should solve the issue
permanently.
<!-- END: deployment -->

View File

@ -1,4 +1,3 @@
# REDIRECTS FILE
#
# See https://www.netlify.com/docs/redirects/ for documentation. Please do not

View File

@ -2,5 +2,5 @@
"compilerOptions": {
"baseUrl": "."
},
"exclude": ["node_modules", ".next", ".mdx-data", "out"]
"exclude": ["node_modules", ".next", "out"]
}

View File

@ -1,4 +1,3 @@
# This file sets configuration for Netlify
# ref: https://www.netlify.com/docs/netlify-toml-reference/

View File

@ -1,4 +1,5 @@
const withHashicorp = require('@hashicorp/nextjs-scripts')
const redirects = require('./redirects.next')
module.exports = withHashicorp({
transpileModules: ['is-absolute-url', '@hashicorp/react-.*'],
@ -10,13 +11,7 @@ module.exports = withHashicorp({
destination: '/api-docs/:path*',
},
],
redirects: () => [
{
source: '/intro',
destination: '/intro/getting-started',
permanent: false,
},
],
redirects: () => redirects,
env: {
HASHI_ENV: process.env.HASHI_ENV || 'development',
SEGMENT_WRITE_KEY: 'OdSFDq9PfujQpmkZf03dFpcUlywme4sC',

View File

@ -47,6 +47,7 @@
"export": "next export",
"format": "next-hashicorp format",
"generate:component": "next-hashicorp generate component",
"generate:readme": "next-hashicorp markdown-blocks README.md",
"linkcheck": "linkcheck https://www.vaultproject.io",
"lint": "next-hashicorp lint",
"start": "next-remote-watch ./content/**/*.mdx",

738
website/redirects.next.js Normal file
View File

@ -0,0 +1,738 @@
module.exports = [
{
source: '/intro',
destination: '/intro/getting-started',
permanent: false,
},
{
source: '/api/secret/generic',
destination: '/api-docs/secret/kv',
permanent: true,
},
{
source: '/api/system/renew',
destination: '/api-docs/system/leases',
permanent: true,
},
{
source: '/api/system/revoke-force',
destination: '/api-docs/system/leases',
permanent: true,
},
{
source: '/api/system/revoke-prefix',
destination: '/api-docs/system/leases',
permanent: true,
},
{
source: '/api/system/revoke',
destination: '/api-docs/system/leases',
permanent: true,
},
{
source: '/docs/auth/aws-ec2',
destination: '/docs/auth/aws',
permanent: true,
},
{
source: '/docs/commands/environment',
destination: '/docs/commands/#environment-variables',
permanent: true,
},
{
source: '/docs/commands/help',
destination: '/docs/commands/path-help',
permanent: true,
},
{
source: '/docs/commands/read-write',
destination: '/docs/commands#reading-and-writing-data',
permanent: true,
},
{
source: '/docs/config',
destination: '/docs/configuration',
permanent: true,
},
{
source: '/docs/configuration/storage/google-cloud',
destination: '/docs/configuration/storage/google-cloud-storage',
permanent: true,
},
{
source: '/docs/configuration/storage/spanner',
destination: '/docs/configuration/storage/google-cloud-spanner',
permanent: true,
},
{
source: '/docs/enterprise/auto-unseal',
destination: '/docs/concepts/seal.html',
permanent: true,
},
{
source: '/docs/enterprise/hsm/configuration',
destination: '/docs/configuration/seal/pkcs11',
permanent: true,
},
{
source: '/docs/enterprise/ui',
destination: '/docs/configuration/ui',
permanent: true,
},
{
source: '/docs/enterprise/automated-raft-snapshots',
destination: '/docs/enterprise/automated-integrated-storage-snapshots',
permanent: true,
},
{
source: '/docs/guides/generate-root',
destination: '/guides/operations/generate-root',
permanent: true,
},
{ source: '/docs/guides', destination: '/guides', permanent: true },
{
source: '/docs/guides/production',
destination: '/guides/operations/production',
permanent: true,
},
{
source: '/docs/guides/replication',
destination: '/guides/operations/replication',
permanent: true,
},
{
source: '/docs/guides/upgrading',
destination: '/docs/upgrading',
permanent: true,
},
{
source: '/docs/http/sys-audit',
destination: '/api-docs/system/audit',
permanent: true,
},
{
source: '/docs/http/sys-auth',
destination: '/api-docs/system/auth',
permanent: true,
},
{
source: '/docs/http/sys-health',
destination: '/api-docs/system/health',
permanent: true,
},
{
source: '/docs/http/sys-init',
destination: '/api-docs/system/init',
permanent: true,
},
{
source: '/docs/http/sys-key-status',
destination: '/api-docs/system/key-status',
permanent: true,
},
{
source: '/docs/http/sys-leader',
destination: '/api-docs/system/leader',
permanent: true,
},
{
source: '/docs/http/sys-mounts',
destination: '/api-docs/system/mounts',
permanent: true,
},
{
source: '/docs/http/sys-policy',
destination: '/api-docs/system/policy',
permanent: true,
},
{
source: '/docs/http/sys-raw',
destination: '/api-docs/system/raw',
permanent: true,
},
{
source: '/docs/http/sys-rekey',
destination: '/api-docs/system/rekey',
permanent: true,
},
{
source: '/docs/http/sys-remount',
destination: '/api-docs/system/remount',
permanent: true,
},
{
source: '/docs/http/sys-renew',
destination: '/api-docs/system/leases',
permanent: true,
},
{
source: '/docs/http/sys-revoke-prefix',
destination: '/api-docs/system/leases',
permanent: true,
},
{
source: '/docs/http/sys-revoke',
destination: '/api-docs/system/leases',
permanent: true,
},
{
source: '/docs/http/sys-rotate',
destination: '/api-docs/system/rotate',
permanent: true,
},
{
source: '/docs/http/sys-seal-status',
destination: '/api-docs/system/seal-status',
permanent: true,
},
{
source: '/docs/http/sys-seal',
destination: '/api-docs/system/seal',
permanent: true,
},
{
source: '/docs/http/sys-unseal',
destination: '/api-docs/system/unseal',
permanent: true,
},
{
source: '/docs/install/install',
destination: '/docs/install',
permanent: true,
},
{
source: '/docs/secrets/custom',
destination: '/docs/plugin',
permanent: true,
},
{
source: '/docs/secrets/generic',
destination: '/docs/secrets/kv',
permanent: true,
},
{
source: '/docs/vault-enterprise/hsm/behavior',
destination: '/docs/enterprise/hsm/behavior',
permanent: true,
},
{
source: '/docs/vault-enterprise/hsm/configuration',
destination: '/docs/enterprise/hsm/configuration',
permanent: true,
},
{
source: '/docs/vault-enterprise/hsm',
destination: '/docs/enterprise/hsm',
permanent: true,
},
{
source: '/docs/vault-enterprise/hsm/security',
destination: '/docs/enterprise/hsm/security',
permanent: true,
},
{
source: '/docs/vault-enterprise/identity',
destination: '/docs/enterprise/identity',
permanent: true,
},
{
source: '/docs/vault-enterprise',
destination: '/docs/enterprise',
permanent: true,
},
{
source: '/docs/vault-enterprise/mfa',
destination: '/docs/enterprise/mfa',
permanent: true,
},
{
source: '/docs/vault-enterprise/mfa/mfa-duo',
destination: '/docs/enterprise/mfa/mfa-duo',
permanent: true,
},
{
source: '/docs/vault-enterprise/mfa/mfa-okta',
destination: '/docs/enterprise/mfa/mfa-okta',
permanent: true,
},
{
source: '/docs/vault-enterprise/mfa/mfa-pingid',
destination: '/docs/enterprise/mfa/mfa-pingid',
permanent: true,
},
{
source: '/docs/vault-enterprise/mfa/mfa-totp',
destination: '/docs/enterprise/mfa/mfa-totp',
permanent: true,
},
{
source: '/docs/vault-enterprise/replication',
destination: '/docs/enterprise/replication',
permanent: true,
},
{
source: '/docs/vault-enterprise/ui',
destination: '/docs/configuration/ui',
permanent: true,
},
{
source: '/docs/secrets/cassandra',
destination: '/docs/secrets/databases/cassandra',
permanent: true,
},
{
source: '/docs/secrets/mongodb',
destination: '/docs/secrets/databases/mongodb',
permanent: true,
},
{
source: '/docs/secrets/mssql',
destination: '/docs/secrets/databases/mssql',
permanent: true,
},
{
source: '/docs/secrets/mysql',
destination: '/docs/secrets/databases/mysql-maria',
permanent: true,
},
{
source: '/docs/secrets/postgresql',
destination: '/docs/secrets/databases/postgresql',
permanent: true,
},
{
source: '/guides/authentication',
destination: '/guides/identity/authentication',
permanent: true,
},
{
source: '/guides/configuration/authentication',
destination: '/guides/identity/authentication',
permanent: true,
},
{
source: '/guides/configuration/generate-root',
destination: '/guides/operations/generate-root',
permanent: true,
},
{
source: '/guides/configuration/lease',
destination: '/guides/identity/lease',
permanent: true,
},
{
source: '/guides/configuration/plugin-backends',
destination: '/guides/operations/plugin-backends',
permanent: true,
},
{
source: '/guides/configuration/policies',
destination: '/guides/identity/policies',
permanent: true,
},
{
source: '/guides/cubbyhole',
destination: '/guides/secret-mgmt/cubbyhole',
permanent: true,
},
{
source: '/guides/dynamic-secret',
destination: '/guides/secret-mgmt/dynamic-secret',
permanent: true,
},
{
source: '/guides/generate-root',
destination: '/guides/operations/generate-root',
permanent: true,
},
{
source: '/guides/lease',
destination: '/guides/identity/lease',
permanent: true,
},
{
source: '/guides/plugin-backends',
destination: '/guides/operations/plugin-backends',
permanent: true,
},
{
source: '/guides/policies',
destination: '/guides/identity/policies',
permanent: true,
},
{
source: '/guides/production',
destination: '/guides/operations/production',
permanent: true,
},
{
source: '/guides/rekeying-and-rotating',
destination: '/guides/operations/rekeying-and-rotating',
permanent: true,
},
{
source: '/guides/replication',
destination: '/guides/operations/replication',
permanent: true,
},
{
source: '/guides/static-secrets',
destination: '/guides/secret-mgmt/static-secrets',
permanent: true,
},
{
source: '/intro/getting-started/acl',
destination: '/intro/getting-started/policies',
permanent: true,
},
{
source: '/intro/getting-started/secret-backends',
destination: '/intro/getting-started/secrets-engines',
permanent: true,
},
{
source: '/guides/configuration/rekeying-and-rotating',
destination: '/guides/operations/rekeying-and-rotating',
permanent: true,
},
{
source: '/docs/guides/upgrading/:path*',
destination: '/docs/upgrading/:path*',
permanent: true,
},
{
source: '/guides/upgrading/:path*',
destination: '/docs/upgrading/:path*',
permanent: true,
},
{
source: '/docs/install/upgrade-:path*',
destination: '/docs/upgrading/upgrade-:path*',
permanent: true,
},
{
source: '/docs/install/upgrade',
destination: '/docs/upgrading',
permanent: true,
},
// Guides and Intro redirects to Learn
{
source: '/guides/getting-started',
destination: 'https://learn.hashicorp.com/vault',
permanent: true,
},
{
source: '/guides/operations',
destination: 'https://learn.hashicorp.com/collections/vault/operations',
permanent: true,
},
{
source: '/guides/operations/reference-architecture',
destination:
'https://learn.hashicorp.com/tutorials/vault/reference-architecture',
permanent: true,
},
{
source: '/guides/operations/deployment-guide',
destination: 'https://learn.hashicorp.com/tutorials/vault/deployment-guide',
permanent: true,
},
{
source: '/guides/operations/vault-ha-consul',
destination: 'https://learn.hashicorp.com/tutorials/vault/ha-with-consul',
permanent: true,
},
{
source: '/guides/operations/production',
destination:
'https://learn.hashicorp.com/tutorials/vault/production-hardening',
permanent: true,
},
{
source: '/guides/operations/generate-root',
destination: 'https://learn.hashicorp.com/tutorials/vault/generate-root',
permanent: true,
},
{
source: '/guides/operations/rekeying-and-rotating',
destination:
'https://learn.hashicorp.com/tutorials/vault/rekeying-and-rotating',
permanent: true,
},
{
source: '/guides/operations/plugin-backends',
destination: 'https://learn.hashicorp.com/tutorials/vault/plugin-backends',
permanent: true,
},
{
source: '/guides/operations/replication',
destination:
'https://learn.hashicorp.com/tutorials/vault/performance-replication',
permanent: true,
},
{
source: '/guides/operations/disaster-recovery',
destination:
'https://learn.hashicorp.com/tutorials/vault/disaster-recovery',
permanent: true,
},
{
source: '/guides/operations/mount-filter',
destination: 'https://learn.hashicorp.com/tutorials/vault/paths-filter',
permanent: true,
},
{
source: '/guides/operations/performance-nodes',
destination:
'https://learn.hashicorp.com/tutorials/vault/performance-standbys',
permanent: true,
},
{
source: '/guides/operations/multi-tenant',
destination: 'https://learn.hashicorp.com/tutorials/vault/namespaces',
permanent: true,
},
{
source: '/guides/operations/autounseal-aws-kms',
destination:
'https://learn.hashicorp.com/tutorials/vault/autounseal-aws-kms',
permanent: true,
},
{
source: '/guides/operations/seal-wrap',
destination: 'https://learn.hashicorp.com/tutorials/vault/seal-wrap',
permanent: true,
},
{
source: '/guides/operations/monitoring',
destination: 'https://learn.hashicorp.com/tutorials/vault/monitoring',
permanent: true,
},
// Identity
{
source: '/guides/identity',
destination: 'https://learn.hashicorp.com/collections/vault/operations',
permanent: true,
},
{
source: '/guides/identity/secure-intro',
destination:
'https://learn.hashicorp.com/tutorials/vault/secure-introduction',
permanent: true,
},
{
source: '/guides/identity/policies',
destination: 'https://learn.hashicorp.com/tutorials/vault/policies',
permanent: true,
},
{
source: '/guides/identity/policy-templating',
destination:
'https://learn.hashicorp.com/tutorials/vault/policy-templating',
permanent: true,
},
{
source: '/guides/identity/authentication',
destination: 'https://learn.hashicorp.com/tutorials/vault/approle',
permanent: true,
},
{
source: '/guides/identity/approle-trusted-entities',
destination:
'https://learn.hashicorp.com/tutorials/vault/approle-trusted-entities',
permanent: true,
},
{
source: '/guides/identity/lease',
destination: 'https://learn.hashicorp.com/tutorials/vault/tokens',
permanent: true,
},
{
source: '/guides/identity/identity',
destination: 'https://learn.hashicorp.com/tutorials/vault/identity',
permanent: true,
},
{
source: '/guides/identity/sentinel',
destination: 'https://learn.hashicorp.com/tutorials/vault/sentinel',
permanent: true,
},
{
source: '/guides/identity/control-groups',
destination: 'https://learn.hashicorp.com/tutorials/vault/control-groups',
permanent: true,
},
// Secrets management
{
source: '/guides/secret-mgmt/index.html',
destination:
'https://learn.hashicorp.com/collections/vault/secrets-management',
permanent: true,
},
{
source: '/guides/secret-mgmt/static-secrets',
destination:
'https://learn.hashicorp.com/vault/secrets-management/sm-static-secrets',
permanent: true,
},
{
source: '/guides/secret-mgmt/versioned-kv',
destination:
'https://learn.hashicorp.com/vault/secrets-management/sm-versioned-kv',
permanent: true,
},
{
source: '/guides/secret-mgmt/dynamic-secrets',
destination:
'https://learn.hashicorp.com/vault/secrets-management/sm-dynamic-secrets',
permanent: true,
},
{
source: '/guides/secret-mgmt/db-root-rotation',
destination:
'https://learn.hashicorp.com/vault/secrets-management/db-root-rotation',
permanent: true,
},
{
source: '/guides/secret-mgmt/cubbyhole',
destination:
'https://learn.hashicorp.com/vault/secrets-management/sm-cubbyhole',
permanent: true,
},
{
source: '/guides/secret-mgmt/ssh-otp',
destination:
'https://learn.hashicorp.com/vault/secrets-management/sm-ssh-otp',
permanent: true,
},
{
source: '/guides/secret-mgmt/pki-engine',
destination:
'https://learn.hashicorp.com/vault/secrets-management/sm-pki-engine',
permanent: true,
},
{
source: '/guides/secret-mgmt/app-integration',
destination:
'https://learn.hashicorp.com/vault/developer/sm-app-integration',
permanent: true,
},
// Encryption
{
source: '/guides/encryption',
destination:
'https://learn.hashicorp.com/collections/vault/encryption-as-a-service',
permanent: true,
},
{
source: '/guides/encryption/transit',
destination:
'https://learn.hashicorp.com/vault/encryption-as-a-service/eaas-transit',
permanent: true,
},
{
source: '/guides/encryption/spring-demo',
destination:
'https://learn.hashicorp.com/vault/encryption-as-a-service/eaas-spring-demo',
permanent: true,
},
{
source: '/guides/encryption/transit-rewrap',
destination:
'https://learn.hashicorp.com/vault/encryption-as-a-service/eaas-transit-rewrap',
permanent: true,
},
// Intro getting started content -> Learn
{
source: '/intro',
destination:
'https://learn.hashicorp.com/collections/vault/getting-started',
permanent: true,
},
{
source: '/intro/getting-started',
destination: 'https://learn.hashicorp.com/vault/getting-started/install',
permanent: true,
},
{
source: '/intro/getting-started/install',
destination:
'https://learn.hashicorp.com/tutorials/vault/getting-started-install',
permanent: true,
},
{
source: '/intro/getting-started/dev-server',
destination: 'https://learn.hashicorp.com/vault/getting-started/dev-server',
permanent: true,
},
{
source: '/intro/getting-started/first-secret',
destination:
'https://learn.hashicorp.com/vault/getting-started/first-secret',
permanent: true,
},
{
source: '/intro/getting-started/secrets-engines',
destination:
'https://learn.hashicorp.com/vault/getting-started/secrets-engines',
permanent: true,
},
{
source: '/intro/getting-started/dynamic-secrets',
destination:
'https://learn.hashicorp.com/vault/getting-started/dynamic-secrets',
permanent: true,
},
{
source: '/intro/getting-started/help',
destination: 'https://learn.hashicorp.com/vault/getting-started/help',
permanent: true,
},
{
source: '/intro/getting-started/authentication',
destination:
'https://learn.hashicorp.com/vault/getting-started/authentication',
permanent: true,
},
{
source: '/intro/getting-started/policies',
destination: 'https://learn.hashicorp.com/vault/getting-started/policies',
permanent: true,
},
{
source: '/intro/getting-started/deploy',
destination: 'https://learn.hashicorp.com/vault/getting-started/deploy',
permanent: true,
},
{
source: '/intro/getting-started/apis',
destination: 'https://learn.hashicorp.com/vault/getting-started/apis',
permanent: true,
},
{
source: '/intro/getting-started/next-steps',
destination: 'https://learn.hashicorp.com/vault/getting-started/next-steps',
permanent: true,
},
// Rearranged out of `guides` but still on `.io`
{
source: '/guides/partnerships',
destination: '/docs/partnerships',
permanent: true,
},
{
source: '/intro/use-cases',
destination: '/docs/use-cases',
permanent: true,
},
{ source: '/intro/vs', destination: '/docs/vs', permanent: true },
{ source: '/intro/vs/:path*', destination: '/docs/vs', permanent: true },
{
source: '/intro/what-is-vault',
destination: '/docs/what-is-vault',
permanent: true,
},
// disallow '.html' or '/index.html' in favor of cleaner, simpler paths
{ source: '/:path*/index', destination: '/:path*', permanent: true },
{ source: '/:path*.html', destination: '/:path*', permanent: true },
]