Skip to content

Commit ca46954

Browse files
committed
Adds CLI documentation page, adds canonical URL's
1 parent 06bdae4 commit ca46954

File tree

4 files changed

+116
-9
lines changed

4 files changed

+116
-9
lines changed

lib/views/default.njk

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,8 @@
1919
{% endif %}
2020
<link rel="favicon" href="{{ siteUrl }}/favicons/favicon.png">
2121
<link rel="mask-icon" href="{{ siteUrl }}/favicons/safari_pinned_tab.svg" color="beige">
22-
<link rel="stylesheet" href="/index.css?{{ buildTimestamp }}">
22+
<link rel="canonical" href="{{ siteUrl }}/{{ permalink }}">
23+
<link rel="stylesheet" href="{{ siteUrl }}/index.css?{{ buildTimestamp }}">
2324
<link rel="preconnect" href="https://fonts.googleapis.com">
2425
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
2526
<link rel="stylesheet" href="//fonts.googleapis.com/css2?family=Antonio:wght@600&&family=Inconsolata&display=swap">
@@ -68,11 +69,11 @@
6869
</article>
6970
<aside class="Page-related">
7071
<div style="margin-bottom: 0.5rem;">Go to related</div>
71-
{% if previous %}
72-
<a style="float: left; color: var(--color-dark-gray);" href='/{{ previous.permalink | replace("+", ".")}}'>&larr; Previous: {{ previous.title }}</a>
72+
{% if collection.news.next.length %}
73+
<a style="float: left; color: var(--color-dark-gray);" href='{{ siteUrl }}/{{ collection.news.next[0].permalink }}'>&larr; Previous: {{ collection.news.next.title }}</a>
7374
{%endif%}
74-
{% if next %}
75-
<a style="float: right; color: var(--color-dark-gray);" href='/{{ next.permalink | replace("+", ".")}}'>Next: {{ next.title }} &rarr;</a>
75+
{% if collection.news.previous.length %}
76+
<a style="float: right; color: var(--color-dark-gray);" href='{{ siteUrl }}/{{ collection.news.previous[0].permalink }}'>Next: {{ collection.news.previous.title }} &rarr;</a>
7677
{% endif %}
7778
</aside>
7879
{% endif %}
@@ -90,6 +91,6 @@
9091
<small>&copy; <span itemprop="copyRightYear">2021</span>, <span itemprop="copyRightHolder">webbketje</span>. Content licensed under <a href="http://creativecommons.org/licenses/by/4.0/" itemprop="license">Creative Commons</a>, their respective authors</small>
9192
</footer>
9293
{% block scripts %}{% endblock %}
93-
<script type="text/javascript" src="/index.js"></script>
94+
<script type="text/javascript" src="{{ siteUrl }}/index.js"></script>
9495
</body>
9596
</html>

metalsmith.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ metalsmith
7676
plugins: mappedPlugins,
7777
nodeVersion,
7878
isProduction,
79-
siteUrl: isProduction ? 'https://metalsmith.io' : 'https://localhost:3000',
79+
siteUrl: isProduction ? 'https://metalsmith.io' : 'http://localhost:3000',
8080
buildTimestamp: Date.now(),
8181
cookieMessage: [
8282
'This website may use local storage for purely functional purposes (for example to remember preferences),',
@@ -109,7 +109,8 @@ metalsmith
109109
.use(
110110
permalinks({
111111
match: '**/*.md',
112-
directoryIndex: 'index.md'
112+
directoryIndex: 'index.md',
113+
trailingSlash: true
113114
})
114115
)
115116
.use(

src/docs/cli.md

Lines changed: 105 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,105 @@
1+
---
2+
title: CLI reference
3+
description: 'An up-to-date list of available metalsmith commands: build, init, clean'
4+
draft: false
5+
toc: true
6+
layout: default.njk
7+
order: 6
8+
sitemap:
9+
priority: 0.7
10+
lastmod: 2026-02-09
11+
config:
12+
anchors: true
13+
---
14+
15+
16+
## Metalsmith
17+
18+
{% codeblock "metalsmith --help" %}
19+
```plaintext
20+
Usage: metalsmith [options] [command]
21+
22+
Metalsmith CLI
23+
24+
Options:
25+
-V, --version output the version number
26+
-h, --help display help for command
27+
28+
Commands:
29+
build [options] Run a metalsmith build
30+
init [options] [source] [destination] Initialize a new metalsmith project from a git repo (subpath). Runs a sequence of git and filesystem commands.
31+
Assumes a working git executable in $PATH and properly configured git/ssh configs.
32+
clean [options] [destination] Clean a directory
33+
help [command] display help for command
34+
35+
Examples:
36+
37+
# build from metalsmith.json:
38+
metalsmith
39+
40+
# build from lib/config.json:
41+
metalsmith --config lib/config.json
42+
43+
# override env vars
44+
metalsmith --env NODE_ENV=production TZ=Europe/London
45+
46+
# override DEBUG env var (shortcut)
47+
metalsmith --debug @metalsmith/*
48+
49+
```
50+
{% endcodeblock %}
51+
52+
### metalsmith build
53+
54+
{% codeblock "metalsmith build --help" %}
55+
```plaintext
56+
Usage: metalsmith build [options]
57+
58+
Run a metalsmith build
59+
60+
Options:
61+
-c, --config <path> configuration file location (default: "metalsmith.json")
62+
--env <setting...> Set or override one or more metalsmith environment variables.
63+
--debug Set or override debug namespaces
64+
--dry-run Process metalsmith files without outputting to the file system
65+
-h, --help display help for command
66+
```
67+
{% endcodeblock %}
68+
69+
### metalsmith init
70+
71+
{% codeblock "metalsmith init --help" %}
72+
```plaintext
73+
Usage: metalsmith init [options] [source] [destination]
74+
75+
Initialize a new metalsmith project from a git repo (subpath). Runs a sequence of git and filesystem commands.
76+
Assumes a working git executable in $PATH and properly configured git/ssh configs.
77+
78+
Arguments:
79+
source Source directory (default: "starters/bare")
80+
destination Destination directory, defaults to current directory (default: ".")
81+
82+
Options:
83+
-f, --force Force overwriting a non-empty directory (default: false)
84+
-o, --origin <origin> Origin repository (https or ssh url, or a directory path). Defaults to https://github.com/metalsmith/resources if omitted (default:
85+
"https://github.com/metalsmith/resources")
86+
-h, --help display help for command
87+
```
88+
{% endcodeblock %}
89+
90+
### metalsmith clean
91+
92+
{% codeblock "metalsmith clean --help" %}
93+
```plaintext
94+
Usage: metalsmith clean [options] [destination]
95+
96+
Clean a directory
97+
98+
Arguments:
99+
destination Destination directory, defaults to metalsmith.destination()
100+
101+
Options:
102+
-c, --config [path] configuration file location (default: "metalsmith.json")
103+
-h, --help display help for command
104+
```
105+
{% endcodeblock %}

src/index.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ slug: "home"
55
layout: "home.njk"
66
sitemap:
77
priority: 1.0
8-
lastmod: 2023-03-01
8+
lastmod: 2026-02-09
99
config:
1010
anchors: false
1111

0 commit comments

Comments
 (0)