Skip to content

Local hugo server adds extra leading slash to File.Path when page content is changed. #10364

@GrahamDumpleton

Description

@GrahamDumpleton

What version of Hugo are you using (hugo version)?

$ hugo version

hugo v0.104.3+extended darwin/amd64 BuildDate=unknown

Does this issue reproduce with the latest release?

Believe v0.104.3 is latest version. Was installed using HomeBrew on macOS.

Description of problem.

Create new Hugo site:

% hugo new site quickstart

Change to Hugo site directory:

% cd quickstart

Add two new pages:

% hugo new 01-page.md
% hugo new 02-page.md

Create layouts default directory:

% mkdir -p layouts/_default

Create layouts/_default/baseof.html:

<body>
  {{ block "main" . }}
  {{ end }} 
</body>

Create layouts/_default/index.html:

{{ define "main" }}
<p>
<ul>
{{ range sort .Site.RegularPages "File.Path" }}
    <li>{{ .File.Path }} -- {{ .Page }}</li>
{{ end }}
</ul>
</p>
{{ end }}

Run hugo server with live reload enabled:

% hugo server -D

Open browser window on server URL.

List of pages should be:

01-page.md - Page(/01-page.md)
02-page.md - Page(/02-page.md)

Append content to file content/02-page.md:

% date >> content/02-page.md

Browser page gets refreshed but there is now an extra leading slash being added to the File.Path property of the page which was modified, which breaks page ordering based on file path.

In other words, output now shows:

/02-page.md - Page(//02-page.md)
01-page.md - Page(/01-page.md)

when would expect the output to be unchanged.

This is only something that occurs with live reload. Generating to static content, and when local server first started (before any file changes) are both fine.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions