How to build index.html with custom title and base href

Ionic 4. CLI version 6.9.1

After running “ionic build --prod” the index.html file in our www folder looks like this:

<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="utf-8" />
  <title>Ionic App</title>

  <base href="/" />

How do we configure our build scripts to change the title and base href? I haven’t found anything about the title, but for base href I’ve tried a couple of suggestions, none have worked though:

ionic build --prod --base-href=/ui/
ionic build --prod --base-href /ui/
ionic build --prod -- --base-href=/ui/
ionic build --prod -- --base-href /ui/
ionic build --prod --base-href="/ui/"
ionic build --prod --base-href "/ui/"
ionic build --prod -- --base-href="/ui/"
ionic build --prod -- --base-href "/ui/"

We aren’t building using Cordova because we are running as a PWA.

I suppose I can run a post build script to overwrite the title and base href in index.html, but surely there’s a way to do this within ionic that I’m missing.

If you’re using Angular, you can set baseHref (and/or deployUrl) in angular.json:

"projects": {
  "markls-app": {
    "architect": {
      "build": {
         "options": {
           "baseHref": "/markls-app",
           "deployUrl": "/markls-app"
1 Like