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

fix: handle relative non-root baseURL #25

Merged
merged 1 commit into from
May 5, 2023
Merged

Conversation

kusyka911
Copy link
Contributor

@kusyka911 kusyka911 commented Apr 27, 2023

What problem does this PR solve?

This PR solve issue with deploying site using relative non-root base URL.
Instruction to reproduce:

  1. build website with relative non-root base url
    with config.toml
baseURL = '/kusyka/'

or with CLI options

hugo -b /kusyka/
  1. Create deployment using local instillation of nginx (or you may use docker instead)
    Example nginx configuration /etc/nginx/nginx.conf:
    In this example we have default website in /usr/share/nginx/html/ and hugo website in /usr/share/nginx/kusyka/
http {
    include       mime.types;
    default_type  application/octet-stream;
    sendfile        on;
    keepalive_timeout  65;
    server {
            listen       80;
            server_name  localhost;

            location / {
                root   /usr/share/nginx/html;
                index  index.html index.htm;
            }
    
            location /kusyka {
                root /usr/share/nginx/;
                index  index.html index.htm;
                error_page  404 /kusyka/404.html;
            }
}
  1. try to visit website (better using another device) by remote IP (check firewall configuration if needed)
  2. Pay attention to the result

base_url_issue

Solution

  • fonts not loaded
    • head.html
      place built css file to root of the website and rename to style.css
    • _font.scss
      use root relative URL for fonts
  • icons not loaded
    • regenerated icons with realfavicongenerator
    • move all icons to assets directory and load them as a resource in head.html using .RelPermalink
    • favicon.ico placed to site root after build (some browser may request it on root by default)
  • make template for site.webmanifest and browserconfig.xml to fill them with all needed options
    • added more icons for windows tiles
    • added ability to customize some options using params.webmanifest and params.browserconfig

Is this PR adding a new feature?

no

Is this PR related to any issue or discussion?

no

PR Checklist

  • I have verified that the code works as described/as intended.
  • This change adds a social icon which has a permissive license to use it.
  • This change does not include any external library/resources.
  • This change does not include any unrelated scripts (e.g. bash and python scripts).
  • I have enabled maintainer edits for this PR.

@netlify
Copy link

netlify bot commented Apr 27, 2023

Deploy Preview for hugo-blog-awesome ready!

Name Link
🔨 Latest commit 8fe0007
🔍 Latest deploy log https://app.netlify.com/sites/hugo-blog-awesome/deploys/64543911b049a90008beb23d
😎 Deploy Preview https://deploy-preview-25--hugo-blog-awesome.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site settings.

@kusyka911 kusyka911 changed the title fix: handle relative non-root baseURL DRAFT: fix: handle relative non-root baseURL Apr 27, 2023
@kusyka911 kusyka911 changed the title DRAFT: fix: handle relative non-root baseURL fix: handle relative non-root baseURL Apr 27, 2023
@kusyka911 kusyka911 closed this Apr 27, 2023
@kusyka911 kusyka911 reopened this Apr 27, 2023
@kusyka911 kusyka911 marked this pull request as draft April 27, 2023 18:22
@hugo-sid
Copy link
Owner

hugo-sid commented Apr 28, 2023

@kusyka911, this looks pretty exciting.

You are correct: this theme is not yet ready for non-root baseURL (or sub-folder baseURL). It is currently ready for root domain or sub-domain based URLs.

Looking forward to review this.

Thanks for your interest in contributing to this theme.

@kusyka911
Copy link
Contributor Author

@hugo-sid I think there is possibility to make hugo template for site.webmanifest. I'll try to implement this solution.

@github-actions github-actions bot added size/m conflicts This PR has conflicts which must be resolved before it can be reviewed. labels May 4, 2023
@github-actions
Copy link

github-actions bot commented May 4, 2023

This pull request has conflicts with the base branch, please resolve those so that we can review the pull request.

@github-actions
Copy link

github-actions bot commented May 4, 2023

This PR exceeds the recommended size of 200 lines. Kindly ensure that you are NOT addressing multiple issues in one PR. We recommend you to create atomic PRs which focus on a single change.

@github-actions
Copy link

github-actions bot commented May 4, 2023

Conflicts have been resolved! 🎉 A maintainer will soon review the pull request.

@github-actions github-actions bot removed the conflicts This PR has conflicts which must be resolved before it can be reviewed. label May 4, 2023
@github-actions
Copy link

github-actions bot commented May 4, 2023

This PR exceeds the recommended size of 200 lines. Kindly ensure that you are NOT addressing multiple issues in one PR. We recommend you to create atomic PRs which focus on a single change.

@kusyka911
Copy link
Contributor Author

kusyka911 commented May 4, 2023

@hugo-sid updated, please review this. I think I covered all possible scenarios. At least for me everything works good.

@hugo-sid
Copy link
Owner

hugo-sid commented May 4, 2023

Thanks for the hard work @kusyka911.

I think I covered all possible scenarios. At least for me everything works good.

That's great.

If you feel, this PR is ready for review, could you please mark the PR as ready for review? Currently it's a draft PR.

@hugo-sid
Copy link
Owner

hugo-sid commented May 4, 2023

This PR exceeds the recommended size of 200 lines. Kindly ensure that you are NOT addressing multiple issues in one PR. We recommend you to create atomic PRs which focus on a single change.

You may ignore this warning, since you are addressing a single issue in this PR.

@github-actions
Copy link

github-actions bot commented May 4, 2023

This PR exceeds the recommended size of 200 lines. Kindly ensure that you are NOT addressing multiple issues in one PR. We recommend you to create atomic PRs which focus on a single change.

@kusyka911 kusyka911 marked this pull request as ready for review May 4, 2023 20:53
@kusyka911
Copy link
Contributor Author

If you feel, this PR is ready for review, could you please mark the PR as ready for review? Currently it's a draft PR.

Done, also added docs.

@github-actions
Copy link

github-actions bot commented May 4, 2023

This PR exceeds the recommended size of 200 lines. Kindly ensure that you are NOT addressing multiple issues in one PR. We recommend you to create atomic PRs which focus on a single change.

@github-actions
Copy link

github-actions bot commented May 4, 2023

This PR exceeds the recommended size of 200 lines. Kindly ensure that you are NOT addressing multiple issues in one PR. We recommend you to create atomic PRs which focus on a single change.

@github-actions
Copy link

github-actions bot commented May 4, 2023

This PR exceeds the recommended size of 200 lines. Kindly ensure that you are NOT addressing multiple issues in one PR. We recommend you to create atomic PRs which focus on a single change.

@sonarcloud
Copy link

sonarcloud bot commented May 5, 2023

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

No Coverage information No Coverage information
No Duplication information No Duplication information

Copy link
Owner

@hugo-sid hugo-sid left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @kusyka911, for this new feature. I think this PR will fix #36.

Thanks for your willingness to improve this theme.

I appreciate your contribution.

@hugo-sid hugo-sid merged commit 058560e into hugo-sid:main May 5, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants