Skip to content

How do I customize blog styles? #2353

Closed

Description

@liushooter

I want to change docusaurus-v2 blog title style,
find this information in @docusaurus/theme-classic/src/theme/BlogPostItem/styles.module.css :

.blogPostTitle {
  font-size: 3rem;
}

I change src/css/custom.css following,no effect :

.blogPostTitle {
  font-size: 1rem;
}

Help me,How do I customize blog styles?

Activity

  1. added
    status: needs triage
    closed: question
    on Mar 4, 2020
  2. liushooter commented on Mar 6, 2020

    @liushooter
    Author

    yeah, i find this https://stackoverflow.com/a/58519684

    yarn swizzle @docusaurus/theme-classic BlogListPage
    yarn swizzle @docusaurus/theme-classic BlogPostItem
    yarn swizzle @docusaurus/theme-classic BlogPostPage
    yarn swizzle @docusaurus/theme-classic BlogTagsListPage
    yarn swizzle @docusaurus/theme-classic BlogTagsPostsPage
    
    yarn swizzle @docusaurus/theme-classic CodeBlock
    
  3. fakela commented on Mar 12, 2020

    @fakela
    Contributor

    @liushooter I had similar issue too, this does not have any effect because it's not properly referenced. It's actually best to style the blog using the styles.module.css and use this src/css/custom.css for styles you want to be available globally. This is what I figured out when trying to style my blog

    @yangshun should be able to give a more detailed explanation

  4. kohheepeace commented on Mar 12, 2020

    @kohheepeace
    Contributor

    @fakela

    1. Run the below command in terminal to swizzle default theme
    yarn swizzle @docusaurus/theme-classic BlogPostItem

    It generates src/theme/BlogPostItem in your website.

    You can overwrite your custom style in src/theme/BlogPostItem/styles.module.css

    Sorry if this is different answer what you want!

  5. fakela commented on Mar 12, 2020

    @fakela
    Contributor

    @kohheepeace thank you alot for this
    I used a different approach
    I had to copy the files and paste them in my website

    This is a lot easier . Thanks

  6. rafaelrdealmeida commented on Nov 3, 2020

    @rafaelrdealmeida

    Hi,

    I'm trying to change the blog layout. But I am not finding the place to customize the layout. Can you indicate that?

    the current layout is this:


    Captura de tela de 2020-11-03 16-49-51

    I'm trying to alteral to:


    Captura de tela de 2020-11-03 17-02-30

  7. slorber commented on Nov 4, 2020

    @slorber
    Collaborator

    hi @rafaelrdealmeida , all the blog components are in the classic theme

    image

    The one displayed in your screenshot looks like the BlogPostList component, that you can swizzle

  8. zRains commented on Dec 15, 2020

    @zRains

    npm version:

    npm run swizzle @docusaurus/theme-classic [component] -- --danger
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

    closed: questionstatus: needs triage

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions