Skip to content

blogTitle is overridden by site title when at site root #10045

Open

Description

@root-io

Have you read the Contributing Guidelines on issues?

Prerequisites

  • I'm using the latest version of Docusaurus.
  • I have tried the npm run clear or yarn clear command.
  • I have tried rm -rf node_modules yarn.lock package-lock.json and re-installing packages.
  • I have tried creating a repro with https://new.docusaurus.io.
  • I have read the console error message carefully (if applicable).

Description

blogTitle not working

Someone at the end of this thread seems to have a similar issue: #5119

Reproducible demo

No response

Steps to reproduce

  presets: [
    [
      'classic',
      {
        blog: {
          routeBasePath: "/",
          blogTitle: "Blog",
        },
      } satisfies Preset.Options,
    ],
  ],

Expected behavior

I want the title of the page to be: "Blog | Foo"

Actual behavior

The blogTitle is not showing, I get the config title twice: "Foo | Foo".

Your environment

  • Public source code:
  • Public site URL:
  • Docusaurus version used: 3.2.1
  • Environment name and version (e.g. Chrome 89, Node.js 16.4):
  • Operating system and version (e.g. Ubuntu 20.04.2 LTS):

Self-service

  • I'd be willing to fix this bug myself.

Activity

  1. added
    bugAn error in the Docusaurus core causing instability or issues with its execution
    status: needs triageThis issue has not been triaged by maintainers
    on Apr 14, 2024
  2. changed the title [-].[/-] [+]blogTitle not working[/+] on Apr 14, 2024
  3. OzakIOne commented on Apr 14, 2024

    @OzakIOne
    Contributor

    Hello I tried when creating a minimal repo and I can't reproduce your issue

    https://stackblitz.com/edit/github-srzyqm?file=docusaurus.config.js

    image

    Please provide a minimal repro on stackblitz with what you want as output so we can further assist you

  4. added
    closed: working as intendedThis issue is intended behavior, there's no need to take any action.
    closed: can't reproThis bug is because of some local setup that can't be reproduced.
    and removed
    bugAn error in the Docusaurus core causing instability or issues with its execution
    status: needs triageThis issue has not been triaged by maintainers
    on Apr 14, 2024
  5. root-io commented on Apr 14, 2024

    @root-io
    Author

    Hey OzaklOne thanks for the stackblitz, I was able to repro using your code with few changes, the important part is routeBasePath: "/", because I want the blog to be hosted on root with no docs or pages. I also deleted the src/pages folder

              blog: {
                blogTitle: 'My blog',
                routeBasePath: "/",
             }
             ...
              // {
              //   type: 'docSidebar',
              //   sidebarId: 'tutorialSidebar',
              //   position: 'left',
              //   label: 'Tutorial',
              // },
              { to: '/', label: 'Blog', position: 'left' },
    
  6. OzakIOne commented on Apr 15, 2024

    @OzakIOne
    Contributor

    From what I tried and understand, when you are in blog only mode blogTitle is not the title of the page anymore, blogTitle is the title of the page when routeBasePath is not set to '/' because title will take the priority over blogTitle and indeed on the route / of your website you will have title twice so by default 'My blog | My blog'

  7. added this to the 4.0 milestone on Apr 15, 2024
  8. slorber commented on Apr 15, 2024

    @slorber
    Collaborator

    Yes that looks like we have this historical behavior in the theme:

    function BlogListPageMetadata(props: Props): JSX.Element {
      const {metadata} = props;
      const {
        siteConfig: {title: siteTitle},
      } = useDocusaurusContext();
      const {blogDescription, blogTitle, permalink} = metadata;
      const isBlogOnlyMode = permalink === '/';
      const title = isBlogOnlyMode ? siteTitle : blogTitle;
      return (
        <>
          <PageMetadata title={title} description={blogDescription} />
          <SearchMetadata tag="blog_posts_list" />
        </>
      );
    }

    I'd consider it a bug because that looks wrong to me.

    Having a blog homepage at / does not mean a site only contains a blog. You might have a blog at the root of your site and yet have docs.

    I'm not sure how we'll fix it yet, but this will likely be done as part of a global siteTitle breaking-change PR where we change other things as well.

    In the meantime you can swizzle BlogListPageMetadata and fix that behavior, use the siteConfig.title if you only host a blog.

  9. added
    bugAn error in the Docusaurus core causing instability or issues with its execution
    and removed
    closed: working as intendedThis issue is intended behavior, there's no need to take any action.
    closed: can't reproThis bug is because of some local setup that can't be reproduced.
    on Apr 15, 2024
  10. changed the title [-]blogTitle not working[/-] [+]blogTitle is overridden by site title when at site root[/+] on Jul 18, 2024
  11. kalyan90 commented on Oct 3, 2024

    @kalyan90

    @slorber I would like to work on this, can you please help with the expected behaviour?

  12. japj commented on Mar 3, 2025

    @japj

    I also just ran into this for my site, where a blog is hosted at '/', but it also contains some documentation under '/docs'.

    I was expecting "Blog|my site", but got "my site|my site" instead as title.

  13. japj commented on Mar 3, 2025

    @japj

    I am fairly new to docusaurus and react, but managed to swizzle eject BlogListPage (since BlogListMetadata seems to be part of that): japj/japj.github.io@8283578#diff-a513ae010e0223ea74a6354e97b3df6476835c573e0bfa189283e2f5b3e5c9f5R23

    Is this the 'correct' way, or is there a better way to do this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugAn error in the Docusaurus core causing instability or issues with its execution

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions