Skip to content

Commit 30c96fa

Browse files
authored
Add support for _redirects, and configure it for the blog posts (#417)
1 parent 9fd5c5e commit 30c96fa

7 files changed

Lines changed: 40 additions & 7 deletions

File tree

.cspell.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ words:
44
- chalin
55
- docset
66
- Docsy
7+
- errorf
78
- gohugoio
89
- Goldydocs
910
- pageinfo

content/en/blog/_index.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
---
22
title: Blog
3+
aliases: [/blog/2018/*]
34
menu: { main: { weight: 30 } }
45
---
56

content/fa/blog/_index.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
---
2-
title: بلاگ داکسی
3-
linkTitle: بلاگ
4-
menu: {main: {weight: 30}}
2+
# cSpell:disable
3+
title: بلاگ
4+
aliases: [ /blog/2018/* ]
5+
menu: { main: { weight: 30 } }
56
---
67

78
اینجا قسمت **بلاگ** است و دو دسته بندی دارد: اخبار و نسخه های منتشر شده.

content/fa/blog/news/_index.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
---
2+
# cSpell:disable
23
title: اخبار
34
---

content/fa/blog/news/first-post/index.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
---
2-
date: 2018-10-06
2+
date: 2026-02-10
33
# cSpell:disable
44
title: مستدات راحت با داکسی
55
linkTitle: معرفی داکسی
6-
description: "پوسته داکسی، قدرت گرفته از هوگو باعث می‌شود که سازندگان پروژه تمرکز خود را روی ساخت مطالب قرار دهند و نیازی به ساخت وبسایت نداشته باشد."
76
author: '[Patrice Chalin](https://github.com/chalin)'
7+
description: "پوسته داکسی، قدرت گرفته از هوگو باعث می‌شود که سازندگان پروژه تمرکز خود را روی ساخت مطالب قرار دهند و نیازی به ساخت وبسایت نداشته باشد."
88
---
99

1010
**این یک نوشته معمولی شامل تصویر می باشد.**

hugo.yaml

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
baseURL: https://example.docsy.dev
22
title: Goldydocs
33

4-
# cSpell:ignore goldmark github hugo readingtime docsy subdir lastmod pygments linenos catmullrom norsk gu
4+
# cSpell:ignore goldmark github hugo readingtime docsy subdir lastmod pygments linenos catmullrom norsk gu slugorcontentbasename
55

66
# Language settings
77
contentDir: content/en
@@ -32,9 +32,20 @@ pygmentsUseClassic: false
3232
# See https://help.farbox.com/pygments.html
3333
pygmentsStyle: tango
3434

35+
mediaTypes:
36+
text/redirects:
37+
delimiter: ''
38+
39+
outputFormats:
40+
redirects:
41+
baseName: _redirects
42+
isPlainText: true
43+
mediaType: text/redirects
44+
root: true
45+
3546
# Configure how URLs look like per section.
3647
permalinks:
37-
blog: /:section/:year/:month/:day/:slug/
48+
blog: /:section/:year/:month/:day/:slugorcontentbasename
3849

3950
# Image processing configuration.
4051
imaging:
@@ -87,6 +98,7 @@ markup:
8798

8899
# Comment out if you don't want the "print entire section" link enabled.
89100
outputs:
101+
home: [HTML, print, RSS, redirects]
90102
section: [HTML, print, RSS]
91103

92104
params:

layouts/home.redirects

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
{{/*
2+
3+
Adapted from https://gohugo.io/methods/page/aliases/#template-implementation
4+
5+
cSpell:ignore hugo
6+
*/ -}}
7+
8+
{{ range .Sites -}}
9+
{{ range $p := .Pages -}}
10+
{{ range .Aliases -}}
11+
{{ if findRE `\s` . -}}
12+
{{ errorf "One of the front matter aliases in %q contains whitespace" $p.String -}}
13+
{{ end -}}
14+
{{ printf "%s %s 301\n" . $p.RelPermalink -}}
15+
{{ end -}}
16+
{{ end -}}
17+
{{ end -}}

0 commit comments

Comments
 (0)