> Portal Navigation:
> 
> - Append `.md` to any URL under `https://dev.wix.com/docs/` to get its markdown version.
> - Pages are either content pages (article or reference text) or menu pages (a list of links to child pages).
> - To get a menu page, truncate any URL to a parent path and append `.md` (e.g. `https://dev.wix.com/docs/sdk.md`, `https://dev.wix.com/docs/sdk/core-modules.md`).
> - Top-level index of all portals: https://dev.wix.com/docs/llms.txt
> - Full concatenated docs: https://dev.wix.com/docs/llms-full.txt

# GetSiteUrl

# Package: richContent

# Namespace: RicosSiteContext

# Method link: https://dev.wix.com/docs/api-reference/assets/rich-content/site-context-v1/get-site-url.md

## Permission Scopes:
Read Site Context for Rich Content: SCOPE.DC-RICOS.READ-SITE-CONTEXT

## Introduction

Retrieves the base URL of the current site and whether the site is published.

Use the base URL to build page URLs for display: `baseUrl` followed by the page's `path`. To match an older link that was stored as a full URL, remove the base URL from it to get the `path`.

To list the pages of the site, call [List Static Pages](https://dev.wix.com/docs/api-reference/assets/rich-content/site-context-v1/list-static-pages.md), [List Dynamic Pages](https://dev.wix.com/docs/api-reference/assets/rich-content/site-context-v1/list-dynamic-pages.md) and [List Dynamic Item Pages](https://dev.wix.com/docs/api-reference/assets/rich-content/site-context-v1/list-dynamic-item-pages.md).

---

## REST API

### Schema

```
 Method: getSiteUrl
 Description: Retrieves the base URL of the current site and whether the site is published.  Use the base URL to build page URLs for display: `baseUrl` followed by the page's `path`. To match an older link that was stored as a full URL, remove the base URL from it to get the `path`.  To list the pages of the site, call [List Static Pages](https://dev.wix.com/docs/api-reference/assets/rich-content/site-context-v1/list-static-pages.md), [List Dynamic Pages](https://dev.wix.com/docs/api-reference/assets/rich-content/site-context-v1/list-dynamic-pages.md) and [List Dynamic Item Pages](https://dev.wix.com/docs/api-reference/assets/rich-content/site-context-v1/list-dynamic-item-pages.md).
 URL: https://www.wixapis.com/ricos/v1/site-context/site-url
 Method: GET
 Return type: GetSiteUrlResponse
  - name: baseUrl | type: string | description: Base URL of the site. It doesn't end with a slash, and a free Wix site includes the site name as a sub-path. For example, `https://www.example.com` or `https://username.wixsite.com/mysite`. For a site that isn't published, it's the free URL that the site gets when it's published.  To build a page URL, append the page's `path`, which always starts with `/`.  | validation: maxLength 4000
  - name: published | type: boolean | description: Whether the site is published. If `false`, the item pages of dynamic pages aren't available yet, and page URLs can't be reached by visitors yet.  


```

### Examples

### Get site URL
Retrieves the base URL of the site and whether it's published

```curl
curl -X GET \
'https://www.wixapis.com/ricos/v1/site-context/site-url' \
-H 'Authorization: <AUTH>'
```

---

## JavaScript SDK

### Schema

```
 Method: wixClientAdmin.richContent.ricosSiteContext.getSiteUrl()
 Description: Retrieves the base URL of the current site and whether the site is published.  Use the base URL to build page URLs for display: `baseUrl` followed by the page's `path`. To match an older link that was stored as a full URL, remove the base URL from it to get the `path`.  To list the pages of the site, call [List Static Pages](https://dev.wix.com/docs/api-reference/assets/rich-content/site-context-v1/list-static-pages.md), [List Dynamic Pages](https://dev.wix.com/docs/api-reference/assets/rich-content/site-context-v1/list-dynamic-pages.md) and [List Dynamic Item Pages](https://dev.wix.com/docs/api-reference/assets/rich-content/site-context-v1/list-dynamic-item-pages.md).
 Return type: PROMISE<GetSiteUrlResponse>
  - name: baseUrl | type: string | description: Base URL of the site. It doesn't end with a slash, and a free Wix site includes the site name as a sub-path. For example, `https://www.example.com` or `https://username.wixsite.com/mysite`. For a site that isn't published, it's the free URL that the site gets when it's published.  To build a page URL, append the page's `path`, which always starts with `/`.  | validation: maxLength 4000
  - name: published | type: boolean | description: Whether the site is published. If `false`, the item pages of dynamic pages aren't available yet, and page URLs can't be reached by visitors yet.  


```

### Examples

### Get site URL
Retrieves the base URL of the site and whether it's published.

```javascript
import { ricosSiteContext } from "@wix/rich-content";

async function getSiteUrl() {
  const response = await ricosSiteContext.getSiteUrl();
}

/* Promise resolves to:
 * {
 *   "baseUrl": "https://username.wixsite.com/mysite",
 *   "published": true
 * }
 */

```

### getSiteUrl (self-managed)
Self-managed SDK calls require you to [create a client](https://dev.wix.com/docs/sdk/articles/work-with-the-sdk/about-the-wix-client.md).

```javascript
import { createClient } from '@wix/sdk';
import { ricosSiteContext } from '@wix/rich-content';
// Import the auth strategy for the relevant access type
// Import the relevant host module if needed

const myWixClient = createClient ({
  modules: { ricosSiteContext },
  // Include the auth strategy and host as relevant
});


async function getSiteUrl() {
  const response = await myWixClient.ricosSiteContext.getSiteUrl();
};
```

---