Skip to content

fix: resolve publication manager issue "missing index.html" (#1689)#19

Open
Zayed-Ahmed-dev wants to merge 1 commit into
silexlabs:mainfrom
Zayed-Ahmed-dev:fix/1689-publication-manager
Open

fix: resolve publication manager issue "missing index.html" (#1689)#19
Zayed-Ahmed-dev wants to merge 1 commit into
silexlabs:mainfrom
Zayed-Ahmed-dev:fix/1689-publication-manager

Conversation

@Zayed-Ahmed-dev

Copy link
Copy Markdown

Description

This PR addresses the issue reported in silexlabs/Silex#1689.

Currently, publishing fails and throws an error when there is no first page defined in the website.This PR improves the behavior by:

  • Detecting when no first page is configured
  • Automatically using the current first available page as the index
  • Displaying a notification to inform the user about the fallback behavior

This provides a smoother publishing experience and prevents the publication process from failing unexpectedly.

Changes made

  • Added validation for missing first page during publication
  • Added fallback logic to use the first available page as the index page
  • Added user notification message during publishing
  • Prevented publication failure caused by missing first page configuration

Before

silexbefore.mp4

After

silexAfter.mp4

Related Issue

Related to silexlabs/Silex#1689

@lexoyo lexoyo changed the title fix: resolve publication manager issue (#1689) fix: resolve publication manager issue "missing index.html" (#1689) May 8, 2026

@lexoyo lexoyo left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey Zayed! Thanks for the PR, it fixes #1689 nicely 👍

I did a code review, hope you find it interesting, there is no major problem at all. Just an edge case to handle when there is a data source

Other suggestions only if you feel like it:

  • You could factor the hasIndex check into a function as it is currently done in 2 places (publish() and getHtmlFilesYield())
  • We could use a small unit test but we can add it later maybe in another PR?

Thank you for this, and it's great to have you around !

const name = page?.name || ''
return name.toLowerCase() === 'index'
})
console.log(hasIndex);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

leftover debug log

const siteSettings = { ...this.editor.getModel().get('settings') as WebsiteSettings }
const pages = (projectData.pages as any[]) || []
const hasIndex = pages.some(page => {
const name = page?.name || ''

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

indentation, missing 2 spaces

message:
'No page named "index" found. The first page will be used as homepage. Rename a page to "index" to control homepage.',
})
}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

trailing whitespaces

const pages = (projectData.pages as any[]) || []
const hasIndex = pages.some(page => {
const name = page?.name || ''
return name.toLowerCase() === 'index'

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The same check is done again below in getHtmlFilesYield(), but written differently — that one uses getPageSlug(name). They can disagree on names like "Index Page" or " index " with spaces. Simpler and safer to use the same line in both places: getPageSlug(name) === 'index'.

const slug = getPageSlug(page.get('name'))
let slug = getPageSlug(page.get('name'));
// if no index page exist make the first page as home page
const firstPageId = pages[0]?.getId()

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

pls move this line above the loop as it doesn't change between iterations

type: 'warning',
group: 'publication',
message:
'No page named "index" found. The first page will be used as homepage. Rename a page to "index" to control homepage.',

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice to have / just an idea: maybe we could add which page will become the homepage, pages[0]?.name is available

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

or even better, more like other messages in silex:

`Page "${pages[0]?.name}": Will be used as homepage because no page is named "index". The homepage is the page served at the root URL of your site.`

// Get the data to publish, clone the objects because plugins can change it
const projectData = { ...this.editor.getProjectData() as WebsiteData }
const siteSettings = { ...this.editor.getModel().get('settings') as WebsiteSettings }
const pages = (projectData.pages as any[]) || []

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

pages could/should be a Page[] right?
you probably want
const pages = projectData.pages ?? [] as Page[]


// Transform the file paths
const slug = getPageSlug(page.get('name'))
let slug = getPageSlug(page.get('name'));

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no semicolons in this project — drop the ; at the end

return name.toLowerCase() === 'index'
})
console.log(hasIndex);
if (!hasIndex) {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

when the site has a data source, the user probably use custom permalinks per page, so the fix isn't needed and breaks publication in some cases

please skip both the warning and the fix when a data source is configured. You can use enable11ty() from cms/publication.ts to know if there is a data source

// if no index page exist make the first page as home page
const firstPageId = pages[0]?.getId()

if (!hasIndex && page.getId() === firstPageId) {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

here too, skip the fix when a data source is configured

@lexoyo

lexoyo commented May 28, 2026

Copy link
Copy Markdown
Member

Hi @Zayed-Ahmed-dev, just a friendly check-in on this PR.

It has been quiet for about 3 weeks since the last review round, and we want to be respectful of your time: are you still planning to work on the requested changes, or have your priorities changed?

Either answer is totally fine. If you have time and want to continue, the review comments are ready to address. If not, just let us know and we can close the PR or pick it up later on our side.

Thanks again for the work you already put into this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants