CaiJimmy / hugo-theme-stack

Card-style Hugo theme designed for bloggers
https://stack.jimmycai.com
GNU General Public License v3.0
4.84k stars 1.55k forks source link

Language convert bug[Bug]: #823

Closed 3kis closed 1 year ago

3kis commented 1 year ago

What happened?

I copy the config.yml from examplesite dir of repo, and I modified something I need, When I try to choose another language mode,my page cannot display properly. proper web page in zh-cn: image

unproper web page in en: image

config.yml:

baseURL: 'https://localhost:1313/'
languageCode: zh-cn
title: My New Hugo Site
theme: stack
paginate: 5

languages:
    en:
        languageName: English
        title: example
        description: Example description
        weight: 1
    zh-cn:
        languageName: 中文
        title: example的个人博客
        description: 演示说明
        weight: 2

# Change it to your Disqus shortname before using
disqusShortname: stack

# GA Tracking ID
googleAnalytics:

# Theme i18n support
# Available values: ar, bn, ca, de, el, en, es, fr, hu, id, it, ja, ko, nl, pt-br, th, uk, zh-cn, zh-hk, zh-tw
DefaultContentLanguage: zh-cn

# Set hasCJKLanguage to true if DefaultContentLanguage is in [zh-cn ja ko]
# This will make .Summary and .WordCount behave correctly for CJK languages.
hasCJKLanguage: true

# 删除了permalinks部分,Hugo将使用默认设置生成永久链接,这通常适用于大多数情况。
# 因此,删除permalinks不会导致任何错误或问题,但如果你希望自定义永久链接的格式,你需要添加适当的permalinks配置来满足你的需求。
# permalinks:
#     post: /p/:slug/
#     page: /:slug/

params:
    mainSections:
        - post
    featuredImageField: image
    rssFullContent: true
    favicon:  # e.g.: favicon placed in `static/favicon.ico` of your site folder, then set this field to `/favicon.ico` (`/` is necessary)

    footer:
        since: 2020
        customText:

    dateFormat:
        published: Jan 02, 2006
        lastUpdated: Jan 02, 2006 15:04 MST

    sidebar:
        emoji: 🍥
        subtitle: Lorem ipsum dolor sit amet, consectetur adipiscing elit.
        avatar:
            enabled: true
            local: true
            src: img/avatar.png

    article:
        math: false
        toc: true
        readingTime: true
        license:
            enabled: true
            default: Licensed under CC BY-NC-SA 4.0

    comments:
        enabled: true
        provider: disqus

        disqusjs:
            shortname:
            apiUrl:
            apiKey:
            admin:
            adminLabel:

        utterances:
            repo:
            issueTerm: pathname
            label:

        remark42:
            host:
            site:
            locale:

        vssue:
            platform:
            owner:
            repo:
            clientId:
            clientSecret:
            autoCreateIssue: false

        # Waline client configuration see: https://waline.js.org/en/reference/component.html
        waline:
            serverURL:
            lang:
            pageview:
            emoji:
                - https://unpkg.com/@waline/emojis@1.0.1/weibo
            requiredMeta:
                - name
                - email
                - url
            locale:
                admin: Admin
                placeholder:

        twikoo:
            envId:
            region:
            path:
            lang:

        # See https://cactus.chat/docs/reference/web-client/#configuration for description of the various options
        cactus:
            defaultHomeserverUrl: "https://matrix.cactus.chat:8448"
            serverName: "cactus.chat"
            siteName: "" # You must insert a unique identifier here matching the one you registered (See https://cactus.chat/docs/getting-started/quick-start/#register-your-site)

        giscus:
            repo:
            repoID:
            category:
            categoryID:
            mapping:
            lightTheme:
            darkTheme:
            reactionsEnabled: 1
            emitMetadata: 0

        gitalk:
            owner:
            admin:
            repo:
            clientID:
            clientSecret:

        cusdis:
            host:
            id:
    widgets:
        homepage:
            - type: search
            - type: archives
              params:
                  limit: 5
            - type: categories
              params:
                  limit: 10
            - type: tag-cloud
              params:
                  limit: 10
        page:
            - type: toc

    opengraph:
        twitter:
            # Your Twitter username
            site:

            # Available values: summary, summary_large_image
            card: summary_large_image

    defaultImage:
        opengraph:
            enabled: false
            local: false
            src:

    colorScheme:
        # Display toggle
        toggle: true

        # Available values: auto, light, dark
        default: auto

    imageProcessing:
        cover:
            enabled: true
        content:
            enabled: true

### Custom menu
### See https://docs.stack.jimmycai.com/configuration/custom-menu.html
### To remove about, archive and search page menu item, remove `menu` field from their FrontMatter
menu:
    main: []

    social:
        - identifier: github
          name: GitHub
          url: https://github.com
          params:
              icon: brand-github

        - identifier: twitter
          name: Twitter
          url: https://twitter.com
          params:
              icon: brand-twitter

related:
    includeNewer: true
    threshold: 60
    toLower: false
    indices:
        - name: tags
          weight: 100

        - name: categories
          weight: 200

markup:
    goldmark:
        renderer:
            ## Set to true if you have HTML content inside Markdown
            unsafe: false
    tableOfContents:
        endLevel: 4
        ordered: true
        startLevel: 2
    highlight:
        noClasses: false
        codeFences: true
        guessSyntax: true
        lineNoStarwot: 1
        lineNos: true
        lineNumbersInTable: true
        tabWidth: 4

What should i do to make the page in en display normally???

我从 repo 的examplesite目录中复制 config.yml,并修改了一些我需要的东西,当我试图选择另一种语言模式时,我的页面无法正确显示。我应该怎么做才能解决这个问题??

Hugo version

latest

Theme version

latest

What browsers are you seeing the problem on?

No response

More information about the browser

No response

Relevant log output

No response

Link to the page with bug

https://demo.stack.jimmycai.com

Link to the source repository

No response

zhixuan2333 commented 1 year ago

index.md 是你的中文稿,添加一个 index.en.md 作为你的英文稿就行了

3kis commented 1 year ago

index.md 是你的中文稿,添加一个 index.en.md 作为你的英文稿就行了

非常感谢,根据你的回复,我解决了这个问题,想请教一下有没有什么办法避免写两份文件呢?? 感觉每次写blog都要写两次的话有点麻烦😮

zhixuan2333 commented 1 year ago

https://gohugo.io/content-management/multilingual/#translation-by-content-directory https://gohugo.io/content-management/multilingual/#bypassing-default-linking 这两个试试吧

BTW,还需要i18n吗?

3kis commented 1 year ago

https://gohugo.io/content-management/multilingual/#translation-by-content-directory https://gohugo.io/content-management/multilingual/#bypassing-default-linking 这两个试试吧

BTW,还需要i18n吗?

Thanks for your help~ i will hava a try