-
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
build.format / trailingSlash / Astro.url / Astro.props.url interactions all seem bolloxed #12833
Comments
Directories will always have trailingSlash. Docs: https://docs.astro.build/en/reference/configuration-reference/#effect-on-astrourl P.s. Also very handy table, should be added to docs, thanks! |
@egnor My website is configured like your row number 3 and I do not have a trailing slash in dev mode with Astro.url. To test it I’ve created a page
The page rendered http://localhost:4321/asd P.s. trailingSlash config option impacts only dev:
|
@egnor wrote
@my-astro replies
I'm sorry, I don't understand how that addresses the inconsistency? @my-astro wrote
I think that's row 8, not row 3? Since you're accessing (Also, you're using an When you say "The page rendered http://localhost:4321/asd", I assume that's using the dev server and accessing @my-astro wrote
I think that's wrong? For example, see the difference between rows 3 and 4 in the "Astro.url build" column -- in fact, Also see #7808 (comment) and other discussions about |
Astro Info
If this issue only occurs in one browser, which browser is a problem?
(browser independent)
Describe the Bug
I am trying to figure out how source files and generated files and URLs interrelate with the various choices for
build.format
(directory
,file
, andpreserve
) andtrailingSlash
(always
,never
, andignore
) and nothing makes any sense.At the URL below I've made a simple exercise case that shows
Astro.url
andAstro.props.url
(and the corresponding.url
property of an imported page) for directory-index and non-directory index files, with a site base of/site_base/
(note trailing slash).Here's what I get:
Astro.url
devAstro.url
buildAstro.props.url
directory
always
directory
ignore
file
never
file
ignore
preserve
ignore
directory
always
directory
ignore
file
never
file
ignore
preserve
ignore
Some things don't make sense to me?
Astro.props.url
fromalways
toignore
drops the trailing slash fromAstro.props.url
but NOT fromAstro.url
?Astro.url
differs between dev and prod??/site_base/
and a generated file ofindex.html
,Astro.props.url
of /site_base.html seems completely wrong.Astro.url
usesanother_page/
instead ofanother_page.html
; meanwhileAstro.props.url
usesanother_page
(no trailing slash)!Astro.url
doesn't matchAstro.props.url
.Also, when using
file
output mode, the dev server has different behavior if you request.../another_file
vs.../another_file/
vs.../another_file.html
, which can't be right since in prod those would all be the same static file. (For the above examples, I always requested.../another_file.html
.)Finally, very strange things happen with
file
+always
ordirectory
+never
, but I'm ignoring that because those are arguably not very sensible combinations??What's the expected result?
A sane, consistent, and well documented approach to the necessary three way mapping between source file layout, output file layout, and assumed URL, without strange variations.
I'm sort of surprised I don't see more people having problems with this, maybe it's because I'm missing something major? Or I guess relatively few people access these metadata fields, people just hardcode URLs?
This is related to the question of how to construct links in Astro -- the docs just say to link to the URL, but to do that you need to know what the URL should be.
Potentially related:
Astro.url.pathname
includes trailing dash when building for SSG but not on dev mode #5630Link to Minimal Reproducible Example
https://github.com/egnor/astro_bug_report
Participation
The text was updated successfully, but these errors were encountered: