Skip to content

Commit 6c40034

Browse files
author
bravegrape
authored
Merge pull request #108 from alphagov/fix-all-broken-links-forever
Fix all broken links and add link checker
2 parents 4667bbb + 5fc0204 commit 6c40034

22 files changed

+503
-35
lines changed

Gemfile

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,6 @@ gem 'govuk_tech_docs'
1111
gem 'therubyracer'
1212

1313
gem 'middleman-gh-pages'
14+
15+
# Include linter to check for dead internal links
16+
gem 'html-proofer'

Gemfile.lock

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,8 @@ GEM
3939
eventmachine (>= 0.12.9)
4040
http_parser.rb (~> 0.6.0)
4141
erubis (2.7.0)
42+
ethon (0.12.0)
43+
ffi (>= 1.3.0)
4244
eventmachine (1.2.7)
4345
execjs (2.7.0)
4446
fast_blank (1.0.0)
@@ -66,6 +68,14 @@ GEM
6668
hamster (3.0.0)
6769
concurrent-ruby (~> 1.0)
6870
hashie (3.6.0)
71+
html-proofer (3.13.0)
72+
addressable (~> 2.3)
73+
mercenary (~> 0.3)
74+
nokogiri (~> 1.10)
75+
parallel (~> 1.3)
76+
rainbow (~> 3.0)
77+
typhoeus (~> 1.3)
78+
yell (~> 2.0)
6979
http_parser.rb (0.6.0)
7080
i18n (0.9.5)
7181
concurrent-ruby (~> 1.0)
@@ -75,6 +85,7 @@ GEM
7585
rb-fsevent (~> 0.9, >= 0.9.4)
7686
rb-inotify (~> 0.9, >= 0.9.7)
7787
memoist (0.16.0)
88+
mercenary (0.3.6)
7889
method_source (0.9.2)
7990
middleman (4.3.5)
8091
coffee-script (~> 2.2)
@@ -130,9 +141,9 @@ GEM
130141
middleman-core (>= 3.2)
131142
rouge (~> 2.0)
132143
mini_portile2 (2.4.0)
133-
minitest (5.12.2)
144+
minitest (5.13.0)
134145
multi_json (1.14.1)
135-
nokogiri (1.10.4)
146+
nokogiri (1.10.5)
136147
mini_portile2 (~> 2.4.0)
137148
openapi3_parser (0.5.2)
138149
commonmarker (~> 0.17)
@@ -150,6 +161,7 @@ GEM
150161
rack (2.0.7)
151162
rack-livereload (0.3.17)
152163
rack
164+
rainbow (3.0.0)
153165
rake (13.0.0)
154166
rb-fsevent (0.10.3)
155167
rb-inotify (0.10.0)
@@ -173,16 +185,20 @@ GEM
173185
thor (0.20.3)
174186
thread_safe (0.3.6)
175187
tilt (2.0.10)
188+
typhoeus (1.3.1)
189+
ethon (>= 0.9.0)
176190
tzinfo (1.2.5)
177191
thread_safe (~> 0.1)
178192
uglifier (3.2.0)
179193
execjs (>= 0.3.0, < 3)
194+
yell (2.2.0)
180195

181196
PLATFORMS
182197
ruby
183198

184199
DEPENDENCIES
185200
govuk_tech_docs
201+
html-proofer
186202
middleman-gh-pages
187203
therubyracer
188204
tzinfo-data

config.rb

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,18 @@
11
require 'govuk_tech_docs'
22

3-
GovukTechDocs.configure(self, livereload: { js_host: "localhost" })
4-
5-
DOCS_LOCATION_IN_GEM = Bundler.rubygems.find_name('govuk_tech_docs').first.full_gem_path + "/docs"
6-
7-
files.watch :source, path: DOCS_LOCATION_IN_GEM
3+
# Check for broken links
4+
require 'html-proofer'
85

9-
helpers do
10-
def gem_docs(filename)
11-
raw_markdown = File.read(DOCS_LOCATION_IN_GEM + "/#{filename}")
12-
13-
# Strip the h1 header from the original markdown file
14-
markdown = raw_markdown.lines[1..-1].join
6+
GovukTechDocs.configure(self, livereload: { js_host: "localhost" })
157

16-
markdown
8+
after_build do |builder|
9+
begin
10+
HTMLProofer.check_directory(config[:build_dir],
11+
{ :assume_extension => true,
12+
:disable_external => true,
13+
:allow_hash_href => true,
14+
:url_swap => { config[:tech_docs][:host] => "" } }).run
15+
rescue RuntimeError => e
16+
abort e.to_s
1717
end
1818
end

source/amend_project/configuration/index.html.md.erb

Lines changed: 224 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,227 @@ review_in: 1 day
77

88
# Configuration options
99

10-
<%= gem_docs 'configuration.md' %>
10+
You can configure the site using `config/tech-docs.yml`. [See the PaaS tech docs for an example](https://github.com/alphagov/paas-tech-docs/blob/master/config/tech-docs.yml).
11+
12+
These are all the available options:
13+
14+
## `ga_tracking_id`
15+
16+
Tracking ID from Google Analytics
17+
18+
```yaml
19+
ga_tracking_id: UA-XXXX-Y
20+
```
21+
22+
## `github_repo`
23+
24+
Your repository. Required if [show_contribution_banner](/amend_project/configuration/#show-contribution-banner) is true.
25+
26+
```yaml
27+
github_repo: alphagov/example-repo
28+
```
29+
30+
## `github_branch`
31+
32+
Your github branch name. Useful if your default branch is not named master.
33+
34+
```yaml
35+
github_branch: source
36+
```
37+
38+
## `google_site_verification`
39+
40+
Adds a [Google Site Verification code](https://support.google.com/webmasters/answer/35179?hl=en) to the meta tags.
41+
42+
```yaml
43+
google_site_verification: TvDTuyvdstyusadrCSDrctyd
44+
```
45+
46+
## `enable_search`
47+
48+
Enables search functionality. This indexes pages only and is not recommended for single-page sites.
49+
50+
```yaml
51+
enable_search: true
52+
```
53+
54+
## `header_links`
55+
56+
Right hand side navigation.
57+
58+
Example:
59+
60+
```yaml
61+
header_links:
62+
Documentation: /
63+
```
64+
65+
## `footer_links`
66+
67+
Links to show in footer.
68+
69+
Example:
70+
71+
```yaml
72+
footer_links:
73+
Accessibility: /accessibility
74+
```
75+
76+
## `host`
77+
78+
Host to use for canonical URL generation (without trailing slash).
79+
80+
Example:
81+
82+
```yaml
83+
host: https://docs.cloud.service.gov.uk
84+
```
85+
86+
## `collapsible_nav`
87+
88+
Enable collapsible navigation in the sidebar. Defaults to false;
89+
90+
```yaml
91+
collapsible_nav: true
92+
```
93+
94+
## `multipage_nav`
95+
96+
Enable multipage navigation in the sidebar. Defaults to false;
97+
98+
```yaml
99+
multipage_nav: true
100+
```
101+
102+
## `max_toc_heading_level`
103+
104+
Table of contents depth – how many levels to include in the table of contents. If your ToC is too long, reduce this number and we'll only show higher-level headings.
105+
106+
```yaml
107+
max_toc_heading_level: 6
108+
```
109+
110+
## `phase`
111+
112+
```yaml
113+
phase: "Beta"
114+
```
115+
116+
## `prevent_indexing`
117+
118+
Prevent robots from indexing (e.g. whilst in development)
119+
120+
```yaml
121+
prevent_indexing: false
122+
```
123+
124+
## `redirects`
125+
126+
A list of redirects, from old to new location. Use this to set up external
127+
redirects or if [setting `old_paths` in the frontmatter](/frontmatter.html#old-paths) doesn't work.
128+
129+
```yaml
130+
redirects:
131+
/old-page.html: https://example.org/something-else.html
132+
/another/old-page.html: /another/new-page.html
133+
```
134+
135+
## `service_name`
136+
137+
The service name in the header.
138+
139+
Example:
140+
141+
```yaml
142+
service_name: "Platform as a Service"
143+
```
144+
145+
## `full_service_name`
146+
147+
The full service name (maybe with GOV.UK)
148+
149+
Example:
150+
151+
```yaml
152+
full_service_name: "GOV.UK Pay"
153+
```
154+
155+
## `service_link`
156+
157+
What the service name in the header links to.
158+
159+
default: '/'
160+
161+
```yaml
162+
service_link: "/"
163+
```
164+
165+
## `show_contribution_banner`
166+
167+
Show a block at the bottom of the page that links to the page source, so readers
168+
can easily contribute back to the documentation. If turned on [github_repo](/amend_project/configuration/#github-repo) is
169+
required.
170+
171+
Off by default.
172+
173+
```yaml
174+
show_contribution_banner: true
175+
github_repo: alphagov/example-repo
176+
```
177+
178+
## `source_urls`
179+
180+
Customise the URLs that the contribution banner links to. Only useful if
181+
[show_contribution_banner](/amend_project/configuration/#show-contribution-banner) is turned on. By default, "Report issue" links
182+
to raising a GitHub issue but by modifying the `report_issue_url` it can link to an email address
183+
or another page.
184+
185+
```yaml
186+
source_urls:
187+
report_issue_url: mailto:support@example.com
188+
```
189+
190+
## `show_govuk_logo`
191+
192+
Whether to show the GOV.UK crown logo.
193+
194+
default: `true`
195+
196+
```yaml
197+
show_govuk_logo: true
198+
```
199+
200+
## `api_path`
201+
202+
Define a path to an Open API V3 spec file. This can be a relative file path or a URI to a raw file.
203+
204+
```yaml
205+
api_path: ./source/pets.yml
206+
```
207+
208+
## `owner_slack_workspace` and `default_owner_slack`
209+
210+
These attributes are used to specify the owner of a page. See the separate
211+
[documentation for page expiry][expiry] for more details.
212+
213+
## `show_expiry`
214+
215+
Decides whether or not to show a red banner when the page needs to be reviewed.
216+
217+
If not present or set to `true`, the red banner will appear when the page needs to be reviewed. This is the default behaviour.
218+
219+
If set to `false`, the red banner will not appear when the page needs to be reviewed.
220+
221+
See the separate [documentation for page expiry][expiry] for more details.
222+
223+
## `show_review_banner`
224+
225+
Decides whether or not to display the page review banner, regardless of whether the page needs to be reviewed or not.
226+
227+
If not present or set to `true`, the banner will be displayed on the page. This is the default behaviour.
228+
229+
If set to `false`, the banner will not be displayed.
230+
231+
See the separate [documentation for page expiry][expiry] for more details.
232+
233+
[expiry]: /review_project/page-expiry/#page-expiry-and-review

source/create_project/multipage/index.html.md.erb

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ You can create a technical documentation site that splits its content across mul
1111

1212
This is suitable for documentation sites that have too much content for the single page format.
1313

14-
You should use the [search feature](/search.html#enable-search) with multipage documentation sites.
14+
You should use the [search feature](/create_project/create_new_project/#enable-search) with multipage documentation sites.
1515

1616
## Basic multipage
1717

@@ -30,15 +30,11 @@ multipage_nav: true
3030

3131
A typical single page documentation repo has this folder structure:
3232

33-
<br/><br/>
34-
![](/diagrams/Single_page.svg)
35-
<br/><br/>
33+
![](/images/Single_page.svg)
3634

3735
A basic multipage documentation repo can have this structure:
3836

39-
<br/><br/>
40-
![](/diagrams/Basic_multipage.svg)
41-
<br/><br/>
37+
![](/images/Basic_multipage.svg)
4238

4339
You must amend the documentation repo folder structure to reflect this structure.
4440

@@ -118,15 +114,11 @@ multipage_nav: true
118114

119115
A typical single page documentation repo has this folder structure:
120116

121-
<br/><br/>
122-
![](/diagrams/Single_page.svg)
123-
<br/><br/>
117+
![](/images/Single_page.svg)
124118

125119
A nested multipage documentation repo can have this structure:
126120

127-
<br/><br/>
128-
![](/diagrams/Nested_multipage.svg)
129-
<br/><br/>
121+
![](/images/Nested_multipage.svg)
130122

131123
You must amend the documentation repo folder structure to reflect this structure.
132124

0 commit comments

Comments
 (0)