|
| 1 | +# Build a multipage site |
| 2 | + |
| 3 | +You can create a technical documentation site that splits its content across multiple pages. |
| 4 | + |
| 5 | +This is suitable for documentation sites that have too much content for the single page format. |
| 6 | + |
| 7 | +You should use the search feature [link] with multipage documentation sites. |
| 8 | + |
| 9 | +## Basic multipage |
| 10 | + |
| 11 | +You can split the content into multiple individual pages. An example is the [GOV.UK PaaS technical documentation](https://docs.cloud.service.gov.uk/). |
| 12 | + |
| 13 | +### Amend the tech-docs.yml file |
| 14 | + |
| 15 | +Add this to your project’s `tech-docs.yml` file, or set it to true if it is already there: |
| 16 | + |
| 17 | +``` |
| 18 | +# Enable multipage navigation in the sidebar |
| 19 | +multipage_nav: true |
| 20 | +``` |
| 21 | + |
| 22 | +### Repo folder structure |
| 23 | + |
| 24 | +A typical single page documentation repo has this folder structure: |
| 25 | + |
| 26 | +<br/><br/> |
| 27 | + |
| 28 | +<br/><br/> |
| 29 | + |
| 30 | +A basic multipage documentation repo can have this structure: |
| 31 | + |
| 32 | +<br/><br/> |
| 33 | + |
| 34 | +<br/><br/> |
| 35 | + |
| 36 | +You must amend the documentation repo folder structure to reflect this structure. |
| 37 | + |
| 38 | +### Create multiple .html.md.erb files |
| 39 | + |
| 40 | +Basic multipage requires multiple `.html.md.erb` files in the tech docs repo __source__ folder. |
| 41 | + |
| 42 | +Each `.html.md.erb` file relates to one separate page within the tech docs, and references the markdown files in the associated folder. |
| 43 | + |
| 44 | +Additionally, the tech doc repo must have at least one `.html.md.erb` file in the __source__ folder named `index.html.md.erb`. |
| 45 | + |
| 46 | +The .html.md.erb files must not have the same name as the folders that the .html.md.erb files use partials refer to. |
| 47 | + |
| 48 | +For example, you cannot have a support.html.md.erb file that contains the partial `<%= partial 'support/contact_us' %>`. |
| 49 | + |
| 50 | +### Amend the multiple .html.md.erb files |
| 51 | + |
| 52 | +1. Add a weight argument and value to the title of each .html.md.erb file. This builds the structure of the multipage documentation. |
| 53 | + |
| 54 | + For example: |
| 55 | + |
| 56 | + ```bash |
| 57 | + --- |
| 58 | + title: "Product Technical Documentation" |
| 59 | + --- |
| 60 | + ``` |
| 61 | + |
| 62 | + becomes |
| 63 | + |
| 64 | + ```bash |
| 65 | + --- |
| 66 | + title: "Product Technical Documentation" |
| 67 | + weight: 10 |
| 68 | + --- |
| 69 | + ``` |
| 70 | + |
| 71 | + Higher weights mean that the content is lower down in the documentation hierarchy. An easy way to remember this is to think “heavier pages sink to the bottom”. |
| 72 | + |
| 73 | + For example, a single `.html.md.erb` file becomes multiple `.html.md.erb` files: |
| 74 | + |
| 75 | + <div style="height:1px;font-size:1px;"> </div> |
| 76 | + |
| 77 | + |Single page|Multipage| |
| 78 | + |:---|:---| |
| 79 | + |---<br>weight: 10<br>title: "Product Technical Documentation"<br>---<br><br><%= partial 'documentation/index' %>|---<br>weight: 10<br>title: "Product Technical Documentation"<br>---<br><br><%= partial 'documentation/index' %>| |
| 80 | + ||---<br>weight: 10<br>title: "Product Technical Documentation"<br>---<br><br><%= partial 'documentation/index' %>| |
| 81 | + ||---<br>weight: 20<br>title: "Product Technical Documentation"<br>---<br><br><%= partial 'documentation/start' %>| |
| 82 | + ||---<br>weight: 30<br>title: "Product Technical Documentation"<br>---<br><br><%= partial 'documentation/users' %>| |
| 83 | + |
| 84 | + <div style="height:1px;font-size:1px;"> </div> |
| 85 | + |
| 86 | +### Add H1 heading if required |
| 87 | + |
| 88 | +Add an H1 heading to either the `.html.md.erb` file or at the start of the first markdown file for each individual content page. |
| 89 | + |
| 90 | +If there is an H1 heading in both, you will see two H1s when the documentation site builds and renders in your internet browser. |
| 91 | + |
| 92 | +## Nested multipage |
| 93 | + |
| 94 | +You can split the content into multiple individual pages, and can have pages "nested" within one another. Two examples: |
| 95 | + |
| 96 | +- [GOV.UK PaaS technical documentation - Deploying services](https://docs.cloud.service.gov.uk/deploying_services/) |
| 97 | +- [GOV.UK Pay technical documentation - Switching to live](https://docs.payments.service.gov.uk/switching_to_live/#switching-to-live) |
| 98 | + |
| 99 | +### Amend the tech-docs.yml file |
| 100 | + |
| 101 | +Add this to your project’s `tech-docs.yml` file, or set it to true if it is already there: |
| 102 | + |
| 103 | +``` |
| 104 | +# Enable multipage navigation in the sidebar |
| 105 | +multipage_nav: true |
| 106 | +``` |
| 107 | + |
| 108 | +### Repo folder structure |
| 109 | + |
| 110 | +A typical single page documentation repo has this folder structure: |
| 111 | + |
| 112 | +<br/><br/> |
| 113 | + |
| 114 | +<br/><br/> |
| 115 | + |
| 116 | +A nested multipage documentation repo can have this structure: |
| 117 | + |
| 118 | +<br/><br/> |
| 119 | + |
| 120 | +<br/><br/> |
| 121 | + |
| 122 | +You must amend the documentation repo folder structure to reflect this structure. |
| 123 | + |
| 124 | +### Create multiple .html.md.erb files |
| 125 | + |
| 126 | +Basic multipage requires multiple `.html.md.erb` files in the tech docs repo __source__ folder. |
| 127 | + |
| 128 | +Each `.html.md.erb` file relates to one separate page within the tech docs, and references the markdown files in the associated folder. |
| 129 | + |
| 130 | +Additionally, the tech doc repo must have at least one `.html.md.erb` file in the __source__ folder named `index.html.md.erb`. |
| 131 | + |
| 132 | +### Amend the multiple .html.md.erb files |
| 133 | + |
| 134 | +1. Add a weight argument and value to the title of each .html.md.erb file. This builds the structure of the multipage documentation. |
| 135 | + |
| 136 | + For example: |
| 137 | + |
| 138 | + ```bash |
| 139 | + --- |
| 140 | + title: "Product Technical Documentation" |
| 141 | + --- |
| 142 | + ``` |
| 143 | + |
| 144 | + becomes |
| 145 | + |
| 146 | + ```bash |
| 147 | + --- |
| 148 | + title: "Product Technical Documentation" |
| 149 | + weight: 10 |
| 150 | + --- |
| 151 | + ``` |
| 152 | + |
| 153 | + Higher weights mean that the content is lower down in the documentation hierarchy. An easy way to remember this is to think “heavier pages sink to the bottom”. |
| 154 | + |
| 155 | + For example, a single `.html.md.erb` file becomes multiple `.html.md.erb` files: |
| 156 | + |
| 157 | + <div style="height:1px;font-size:1px;"> </div> |
| 158 | + |
| 159 | + |Single page|Multipage| |
| 160 | + |:---|:---| |
| 161 | + |---<br>weight: 10<br>title: "Product Technical Documentation"<br>---<br><br><%= partial 'documentation/index' %>|---<br>weight: 10<br>title: "Product Technical Documentation"<br>---<br><br><%= partial 'documentation/index' %>| |
| 162 | + ||---<br>weight: 10<br>title: "Product Technical Documentation"<br>---<br><br><%= partial 'documentation/index' %>| |
| 163 | + ||---<br>weight: 20<br>title: "Product Technical Documentation"<br>---<br><br><%= partial 'documentation/start' %>| |
| 164 | + ||---<br>weight: 30<br>title: "Product Technical Documentation"<br>---<br><br><%= partial 'documentation/users' %>| |
| 165 | + |
| 166 | + <div style="height:1px;font-size:1px;"> </div> |
| 167 | + |
| 168 | +### Add H1 heading if required |
| 169 | + |
| 170 | +Add an H1 heading to either the `.html.md.erb` file or at the start of the first markdown file for each individual content page. |
| 171 | + |
| 172 | +If there is an H1 heading in both, you will see two H1s when the documentation site builds and renders in your internet browser. |
| 173 | + |
| 174 | +### Create folder for nested content .html.md.erb files |
| 175 | + |
| 176 | +Refer to the GOV.UK PaaS technical documentation repo [nested content folder](https://github.com/alphagov/paas-tech-docs/tree/master/source/deploying_services) as an example. |
| 177 | + |
| 178 | +1. Create a folder within the __source__ folder. This is where the `.html.md.erb` files for your nested content must live. |
| 179 | + |
| 180 | +1. Create an `index.html.md.erb` file within the nested content folder. This will be the "wrapper" for the nested content. It can refer to another content file through partials or have the content in itself. |
| 181 | + |
| 182 | + Note that each `.html.md.erb` must have a weight value that preserves the overall hierarchy both within the nested content and compared to the other non-nested content. |
| 183 | + |
| 184 | +1. Create sub-folders for each nested page under the "wrapper". |
| 185 | + |
| 186 | +1. Create an `index.html.md.erb` file within each sub-folder. Each `.html.md.erb` file can refer to another content file through partials or have the content in itself. |
| 187 | + |
| 188 | + Note that each `.html.md.erb` file must have a weight value that preserves the overall hierarchy both within the nested content and compared to the other non-nested content. |
| 189 | + |
| 190 | +### Add H1 heading if required |
| 191 | + |
| 192 | +Add an H1 heading to either the `.html.md.erb` file or at the start of the first markdown file for each individual content page. |
| 193 | + |
| 194 | +If there is an H1 heading in both, you will see two H1s when the documentation site builds and renders in your internet browser. |
0 commit comments