Base
Base renders a <base> tag that sets the default base URL and browsing context for relative links and form submissions within the document. It is scoped to emitting the <base> tag only and does not perform URL validation or resolution.
| prop | type | default | required | description |
|---|---|---|---|---|
href | string | - | No | Base URL used for resolving all relative URLs in the document. |
target | string | - | No | Default browsing context for links and forms in the document. |
Examples
Section titled “Examples”Input:
<Base href="https://example.com" />Output:
<base href="https://example.com" />Automatic
Section titled “Automatic”Uses the integration headTags.base value when no prop is provided.
Input:
// in astro.config.mjs integration configeminence({ headTags: { base: { href: "https://example.com", target: "_blank", }, },});
```astro<Base />Output:
<base href="https://example.com" target="_blank" />Complete
Section titled “Complete”Input:
<Base href="https://example.com" target="_blank" />Output:
<base href="https://example.com" target="_blank" />Decisions Made
Section titled “Decisions Made”Optional props with fallback to integration config
Section titled “Optional props with fallback to integration config”If any prop is provided it overrides all the integration config values. If no props are provided, the component falls back to using the integration config values for head.base.href and head.base.target if they are set.
Reference
Section titled “Reference”- (MDN: base element)[https://developer.mozilla.org/en-US/docs/Web/HTML/Element/base ]
- (WHATWG HTML Standard: base element)[https://html.spec.whatwg.org/multipage/semantics.html#the-base-element]