Skip to content

Make navigation URL generation base-path-aware across GitHub Pages and EMU hosting#223

Draft
saracarl with Copilot wants to merge 14 commits into
developfrom
copilot/implement-base-path-aware-url-generation
Draft

Make navigation URL generation base-path-aware across GitHub Pages and EMU hosting#223
saracarl with Copilot wants to merge 14 commits into
developfrom
copilot/implement-base-path-aware-url-generation

Conversation

Copilot AI commented Jul 7, 2026

Copy link
Copy Markdown

Some internal links were generated by prepending the repository slug, which works for classic github.io/<repo> project pages but breaks when Pages is hosted under a different base path (including EMU setups). This change makes link generation consistently respect the configured Astro base path instead of assuming slug-based hosting.

  • Base-path normalization

    • Centralized path joining logic so URLs are built from the resolved base path (or /), not from project.slug.
    • Normalized leading/trailing slash behavior to avoid // and missing separators.
  • Header / home link

    • Updated the site-title/home anchor to resolve against the computed base path.
    • Removed implicit slug-prepend behavior in production URL construction.
  • Navigation routes (pages/events/tags)

    • Updated nav link builders to compose route targets from the normalized base path + route segment.
    • Applied the same behavior to generated links so pages, events, and tags remain correct in both hosting models.
// before: slug-coupled URL generation
const href = `/${projectSlug}/events/${pageSlug}`;

// after: base-path-aware URL generation
const href = joinBasePath(basePath, `events/${pageSlug}`);

Copilot AI changed the title [WIP] Implement base-path-aware URL generation for GitHub Pages Make navigation URL generation base-path-aware across GitHub Pages and EMU hosting Jul 7, 2026
Copilot AI requested a review from saracarl July 7, 2026 16:37
@@ -1,6 +1,5 @@
---
import { getEntry } from 'astro:content';
import { dynamicConfig } from 'dynamic-astro-config';

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Why was this line removed?

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

@copilot See comment.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

I removed that import because the header no longer uses dynamicConfig for URL building. It now uses import.meta.env.BASE_URL (via normalizeBasePath) so links follow Astro’s configured base path in both classic GitHub Pages and EMU hosting.

@saracarl

saracarl commented Jul 7, 2026

Copy link
Copy Markdown

@copilot That worked well to remove the repo slug from the URL at the project title. It did not fix the URLs in the hamburger menu navigation.

Copilot AI commented Jul 7, 2026

Copy link
Copy Markdown
Author

@copilot That worked well to remove the repo slug from the URL at the project title. It did not fix the URLs in the hamburger menu navigation.

Fixed in 31f43fa. I updated base-path normalization so hamburger-menu links are always built as root-prefixed paths (e.g. /events/... or /base/events/...) instead of relative paths that could carry the repo slug.

@saracarl

saracarl commented Jul 7, 2026

Copy link
Copy Markdown

@copilot That code fix still shows URLs that contain the repo name in the navigation menu. For example, in the repo testing16 which contains a page testing-the-page, the navigation menu shows the url (incorrectly) as
https://animated-telegram-gwvnz7m.pages.github.io/testing16/pages/testing-the-page

Meanwhile the links on the landing page are correctly linking to
https://animated-telegram-gwvnz7m.pages.github.io/pages/testing-the-page/

Copilot AI commented Jul 7, 2026

Copy link
Copy Markdown
Author

@copilot That code fix still shows URLs that contain the repo name in the navigation menu. For example, in the repo testing16 which contains a page testing-the-page, the navigation menu shows the...

Addressed in 44046b0. I switched the Header/Sidebar base-path source from import.meta.env.BASE_URL to dynamicConfig.base, so hamburger menu links now use the same hosting-aware base logic as the rest of the site.

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