@@ -56,7 +56,7 @@ type targetPathDescriptor struct {
5656 // Whether this is a multihost multilingual setup.
5757 IsMultihost bool
5858
59- // Page.URLPath. URL. Will override any Slug etc. for regular pages .
59+ // URL from front matter if set . Will override any Slug etc.
6060 URL string
6161
6262 // Used to create paginator links.
@@ -88,7 +88,7 @@ func (p *Page) initTargetPathDescriptor() error {
8888 Sections : p .sections ,
8989 UglyURLs : p .s .Info .uglyURLs (p ),
9090 Dir : filepath .ToSlash (p .Source .Dir ()),
91- URL : p .URLPath .URL ,
91+ URL : p .URLPath .frontMatterURL ,
9292 IsMultihost : p .s .owner .IsMultihost (),
9393 }
9494
@@ -189,7 +189,7 @@ func createTargetPath(d targetPathDescriptor) string {
189189 isUgly = true
190190 }
191191
192- if d .Kind != KindPage && len (d .Sections ) > 0 {
192+ if d .Kind != KindPage && d . URL == "" && len (d .Sections ) > 0 {
193193 if d .ExpandedPermalink != "" {
194194 pagePath = filepath .Join (pagePath , d .ExpandedPermalink )
195195 } else {
@@ -202,43 +202,42 @@ func createTargetPath(d targetPathDescriptor) string {
202202 pagePath = filepath .Join (pagePath , d .Type .Path )
203203 }
204204
205- if d .Kind == KindPage {
206- // Always use URL if it's specified
207- if d .URL != "" {
208- if d .IsMultihost && d .LangPrefix != "" && ! strings .HasPrefix (d .URL , "/" + d .LangPrefix ) {
209- pagePath = filepath .Join (d .LangPrefix , pagePath , d .URL )
210- } else {
211- pagePath = filepath .Join (pagePath , d .URL )
212- }
213- if strings .HasSuffix (d .URL , "/" ) || ! strings .Contains (d .URL , "." ) {
214- pagePath = filepath .Join (pagePath , d .Type .BaseName + d .Type .MediaType .FullSuffix ())
215- }
205+ if d .Kind != KindHome && d .URL != "" {
206+ if d .IsMultihost && d .LangPrefix != "" && ! strings .HasPrefix (d .URL , "/" + d .LangPrefix ) {
207+ pagePath = filepath .Join (d .LangPrefix , pagePath , d .URL )
216208 } else {
217- if d .ExpandedPermalink != "" {
218- pagePath = filepath .Join (pagePath , d .ExpandedPermalink )
219-
220- } else {
221- if d .Dir != "" {
222- pagePath = filepath .Join (pagePath , d .Dir )
223- }
224- if d .BaseName != "" {
225- pagePath = filepath .Join (pagePath , d .BaseName )
226- }
227- }
209+ pagePath = filepath .Join (pagePath , d .URL )
210+ }
211+ if d .Addends != "" {
212+ pagePath = filepath .Join (pagePath , d .Addends )
213+ } else if strings .HasSuffix (d .URL , "/" ) || ! strings .Contains (d .URL , "." ) {
214+ pagePath = filepath .Join (pagePath , d .Type .BaseName + d .Type .MediaType .FullSuffix ())
215+ }
216+ } else if d .Kind == KindPage {
217+ if d .ExpandedPermalink != "" {
218+ pagePath = filepath .Join (pagePath , d .ExpandedPermalink )
228219
229- if d .Addends != "" {
230- pagePath = filepath .Join (pagePath , d .Addends )
220+ } else {
221+ if d .Dir != "" {
222+ pagePath = filepath .Join (pagePath , d .Dir )
231223 }
232-
233- if isUgly {
234- pagePath += d .Type .MediaType .Delimiter + d .Type .MediaType .Suffix
235- } else {
236- pagePath = filepath .Join (pagePath , d .Type .BaseName + d .Type .MediaType .FullSuffix ())
224+ if d .BaseName != "" {
225+ pagePath = filepath .Join (pagePath , d .BaseName )
237226 }
227+ }
238228
239- if d .LangPrefix != "" {
240- pagePath = filepath .Join (d .LangPrefix , pagePath )
241- }
229+ if d .Addends != "" {
230+ pagePath = filepath .Join (pagePath , d .Addends )
231+ }
232+
233+ if isUgly {
234+ pagePath += d .Type .MediaType .Delimiter + d .Type .MediaType .Suffix
235+ } else {
236+ pagePath = filepath .Join (pagePath , d .Type .BaseName + d .Type .MediaType .FullSuffix ())
237+ }
238+
239+ if d .LangPrefix != "" {
240+ pagePath = filepath .Join (d .LangPrefix , pagePath )
242241 }
243242 } else {
244243 if d .Addends != "" {
0 commit comments