diff --git a/website/docs/cli/commands/fmt.mdx b/website/docs/cli/commands/fmt.mdx index 9dbe2aa827..f9127db496 100644 --- a/website/docs/cli/commands/fmt.mdx +++ b/website/docs/cli/commands/fmt.mdx @@ -9,7 +9,7 @@ description: >- The `terraform fmt` command is used to rewrite Terraform configuration files to a canonical format and style. This command applies a subset of -the [Terraform language style conventions](/terraform/language/syntax/style), +the [Terraform language style conventions](/terraform/language/style#syntax-conventions), along with other minor adjustments for readability. Other Terraform commands that generate Terraform configuration will produce diff --git a/website/docs/language/style.mdx b/website/docs/language/style.mdx index 59031c5456..b3036be3a8 100644 --- a/website/docs/language/style.mdx +++ b/website/docs/language/style.mdx @@ -76,7 +76,7 @@ The Terraform parser allows you some flexibility in how you lay out the elements ## Code formatting -The `terraform fmt` command helps ensure your Terraform code formatting is consistent by applying a subset of the [Terraform language style conventions](/terraform/language/syntax/style), such as those described in the [syntax style recommendations](#syntax-style). When you run this command, Terraform modifies your code to remove trailing whitespace, align arguments, and fix indentation. By default, the `terraform fmt` command will only modify your Terraform code in the directory that you execute it in, but you can include the `-recursive` flag to modify code in all subdirectories as well. +The `terraform fmt` command helps ensure your Terraform code formatting is consistent by applying a subset of the [Terraform language syntax conventions](#syntax-conventions), such as those described in the [syntax style recommendations](#syntax-style). When you run this command, Terraform modifies your code to remove trailing whitespace, align arguments, and fix indentation. By default, the `terraform fmt` command will only modify your Terraform code in the directory that you execute it in, but you can include the `-recursive` flag to modify code in all subdirectories as well. We recommend that you run `terraform fmt` before each commit to source control. You can use mechanisms such as [Git pre-commit hooks](https://git-scm.com/book/en/v2/Customizing-Git-Git-Hooks) to automatically run this command each time you commit your code. diff --git a/website/docs/language/syntax/index.mdx b/website/docs/language/syntax/index.mdx index 199166bb78..8f309d9f50 100644 --- a/website/docs/language/syntax/index.mdx +++ b/website/docs/language/syntax/index.mdx @@ -18,6 +18,6 @@ section offer a more abstract view of the Terraform language. Terraform language. Terraform's JSON syntax is unfriendly to humans, but can be very useful when generating infrastructure as code with other systems that don't have a readily available HCL library. -- [Style Conventions](/terraform/language/syntax/style) documents some commonly +- [Style Conventions](/terraform/language/style#syntax-conventions) documents some commonly accepted formatting guidelines for Terraform code. These conventions can be enforced automatically with [`terraform fmt`](/terraform/cli/commands/fmt).