Skip to content
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

init should include titleTemplate in generated index.mts #3375

Closed
jblachly opened this issue Dec 23, 2023 · 0 comments
Closed

init should include titleTemplate in generated index.mts #3375

jblachly opened this issue Dec 23, 2023 · 0 comments
Labels
bug: pending triage Maybe a bug, waiting for confirmation

Comments

@jblachly
Copy link

Describe the bug

npx vitepress init generates a default .vitepress/config.mts based on user responses, which is helpful. One of these questions/responses is the title of the site. This is inserted into config.mts as the title: kv pair for the config object.

However, when title exists without titleTemplate, the html <title> is rendered with duplication.

For example, if the user answers My Site to the title question, the browser displays in the tab or bookmark the title of the site as "My Site | My Site". This is not only unattractive, but it's difficult to discover why this is happening.

Reproduction

https://stackblitz.com/edit/vite-fmv5pr?file=docs%2F.vitepress%2Fconfig.ts

Open the resulting site @ webcontainer.io in a separate browser window to see the result.

Expected behavior

I expect no duplication. This could be accomplished by:

  1. changing the render code so that if titleTemplate is missing, that title is not rendered as <title>{{ title }} | {{ title }}</title>
  2. Including a titleTemplate in the init questionnaire; or simply including a default value that is different than what the user answered for title

System Info

System:
    OS: macOS 12.6.7
    CPU: (10) arm64 Apple M1 Pro
    Memory: 80.66 MB / 32.00 GB
    Shell: 5.8.1 - /bin/zsh
  Binaries:
    Node: 16.13.0 - /usr/local/bin/node
    npm: 8.1.0 - /usr/local/bin/npm
  Browsers:
    Chrome: 120.0.6099.129
    Safari: 17.1


### Additional context

_No response_

### Validations

- [X] Check if you're on the [latest VitePress version](https://github.com/vuejs/vitepress/releases/latest).
- [X] Follow our [Code of Conduct](https://vuejs.org/about/coc.html)
- [X] Read the [docs](https://vitepress.dev).
- [X] Check that there isn't already an issue that reports the same bug to avoid creating a duplicate.
@jblachly jblachly added the bug: pending triage Maybe a bug, waiting for confirmation label Dec 23, 2023
@brc-dd brc-dd closed this as completed in 9f1f04e Dec 26, 2023
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jan 3, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug: pending triage Maybe a bug, waiting for confirmation
Projects
None yet
Development

No branches or pull requests

1 participant