Skip to content

Latest commit

 

History

History
366 lines (295 loc) · 13.3 KB

README_EN.md

File metadata and controls

366 lines (295 loc) · 13.3 KB

GitHub Checks State GitHub Issues StyleCI GitHub Latest Release GitHub Last Commit Go Report Docker Image Size

中文 | English

Markdown-Blog is incredibly fast, easy to use, and converts Markdown formatted text files into beautifully rendered HTML pages.

Designed with simplicity and ease-of-use in mind, this application allows users to create and publish blog content without the need for complex web development skills. anyone can use this software to create professional-looking blogs with minimal hassle. Whether you're a blogger, writer, or developer, our static blog generator is an excellent choice for creating fast, stylish, and aesthetically pleasing website.

Case

TechMan'Blog

Web side

Style Preveiw
Dark pc dark
Light pc white

Mobile

Dark Light
mobile dark mobile white

Supported Platforms

Windows, Linux, Mac OS

Updates

  • [v1.1.1] 2023-05-20

    • Support setting record number
    • Fix cache parameter invalidation
    • Support reading local files, including but not limited to pictures
    • windows environment parsing problem
    • MD folder, read only markdonw files
    • Other known issues fixed
  • [v1.1.0] 2022-11-26

    • Support for comments
    • Parameter setting, support reading from local file (config.yml)
    • Support for loading favicon.ico
    • Other known issues fixed
  • [v1.0.0] 2022-11-20

    • Support for Docker deployments
    • Packaged static files, optimized for a single application, no more external web directories
    • Other known issues fixed
  • [v0.1.1] 2022-11-12

    • New third-party analysis statistics configuration, including: Baidu, Google
    • Support configuration page cache time
    • Mobile style optimization
    • Other known issues fixed
  • [v0.0.5] 2022-11-06

    • Support TOC syntax, when the first line of the file content using [toc] will be automatically parsed
    • New bright 🔆 theme, support light and dark switch
    • Other known issues fixed

Install

Binary

  1. Download release

  2. Decompress

tar zxf markdown-blog-v0.0.5-linux-amd64.tar.gz
  1. create markdown file directory
cd markdown-blog-linux-amd64
mkdir md
echo "## Hello World" > . /md/home.md
  1. run
. /markdown-blog web
  1. Visit http://127.0.0.1:5006 to see the results

Docker

  1. Download
docker pull willgao/markdown-blog:latest
  1. Start

    • online environment
    docker run -dit --rm --name=markdown-blog \
    -p 5006:5006 \
    -v $(pwd)/md:/md -v $(pwd)/cache:/cache \
    willgao/markdown-blog:latest
    • Development environment
    docker run -dit --rm --name=markdown-blog \
    -p 5006:5006 \
    -v $(pwd)/md:/md -v $(pwd)/cache:/cache \
    willgao/markdown-blog:latest \
    -e dev
  2. Visit http://127.0.0.1:5006 to see the results

  3. Other usage

# View help
docker run -dit --rm --name=markdown-blog \
    -p 5006:5006 \
    -v $(pwd)/md:/md -v $(pwd)/cache:/cache \
    willgao/markdown-blog:latest -h


# Set the title
docker run -dit --rm --name=markdown-blog \
    -p 5006:5006 \
    -v $(pwd)/md:/md -v $(pwd)/cache:/cache \
    willgao/markdown-blog:latest \
    -t "TechMan'Blog"


# Set up Google stats
docker run -dit --rm --name=markdown-blog \
    -p 5006:5006 \
    -v $(pwd)/md:/md -v $(pwd)/cache:/cache \
    willgao/markdown-blog:latest \
    -t "TechMan'Blog" \
    --analyzer-google "De44AJSLDdda"

Use the

command

  • markdown-blog
    • h to view the version
    • web to run the blog service
  • markdown-blog web
    • -config FILE Load configuration file, default is empty
    • -dir value, -d value Specify the markdown folder, default: . /md/
    • -title value, -t value Web service title, default: "Blog"
    • -port value, -p value Web service port, default: 5006
    • -env value, -e value Runtime environment, optional: dev,test,prod, default: "prod"
    • -index value, -i value Set the default home page file name, default is empty
    • -cache value, -c value Set the page cache time, in minutes, default is 3 minutes
    • --icp value ICP record number, default is empty
    • --copyright value Copyright year, default current year, such as: 2023
    • --fdir value The name of the static resource directory under the markdown directory, such as pictures, etc., the default is "public"
    • -analyzer-baidu value Set Baidu analyzer statistics
    • -analyzer-google value Set Google analyzer statistics
    • -gitalk.client-id value Set Gitalk ClientId, default is null
    • -gitalk.client-secret value Set Gitalk ClientSecret, default is null
    • -gitalk.repo value Set Gitalk Repo, default is null
    • -gitalk.owner value Set Gitalk Owner, default is null
    • -gitalk.admin value Set Gitalk Admin, default is array [gitalk.owner]
    • -gitalk.labels value Set Gitalk Admin, default is array ["gitalk"].
    • -ignore-file value Set ignore file, eg: demo.md
    • -ignore-path value Set ignore folders, eg: demo
    • -h Help

Run parameters

Support reading configuration items from configuration file, but specify parameters to take precedence over configuration file at runtime, refer to config/config.yml.tmp for configuration content

Configuration file

  1. create a new configuration file config/config.yml 2.

  2. load the configuration file at startup

  • Binary file
. /markdown-blog web --config . /config/config.yml
  • Docker
docker run -dit --rm --name=markdown-blog \
-p 5006:5006 \
-v $(pwd)/md:/md -v $(pwd)/cache:/cache -v $(pwd)/config:/config \
willgao/markdown-blog:latest --config . /config/config.yml

Default home page

If index is not specified at startup, the program defaults to the first file in the navigation as the home page

Comment plugin

The comment plugin uses Gitalk, please read the plugin instructions before using it English | Chinese gitalk/blob/master/readme-cn.md)

Add a new gitalk configuration file to be loaded at startup

gitalk:
    client-id: "Your github oauth app client-id, required. e.g.: ad549a9d085d7f5736d3"
    client-secret: "Your github oauth app
    client-secret, required. e.g.: 510d1a6bb875fd5031f0d613cd606b1d"
    repo: "The name of the project you intend to use for comments, required. e.g.: blog-issue"
    owner: "Your Github account, required."
    admin:
        - "Your Github account"
    labels:
        - "Custom issue labels, e.g.: gitalk"

Analysis stats

Baidu

1. Visit https://tongji.baidu.com to create a site and get the parameter 0952befd5b7da358ad12fae3437515b1 in the official code
<script>
var _hmt = _hmt || [];
(function() {
var hm = document. createElement("script");
hm.src = "https://hm.baidu.com/hm.js?0952befd5b7da358ad12fae3437515b1";
var s = document. getElementsByTagName("script")[0];
s.parentNode.insertBefore(hm, s);
})();
</script>
2. Configuration
./markdown-blog web --analyzer-baidu 0952befd5b7da358ad12fae3437515b1

Google

1. Visit https://analytics.google.com to create a site and get the parameter G-MYSMYSMYS in the official code
<script async="" src="https://www.googletagmanager.com/gtag/js?id=G-MYSMYSMYS"></script>
<script>
     window.dataLayer = window.dataLayer || [];
     function gtag(){dataLayer. push(arguments);}
     gtag('js', new Date());

     gtag('config', 'G-MYSMYSMYS');
</script>
2. Configuration
./markdown-blog web --analyzer-google G-MYSMYSMYS

Title Bar Icon

By default, read the favicon.ico file in the same directory as the program is running

Navigation Sorting

The blog navigation is sorted by dictionary by default, you can customize the order by the number in front of @

Personal blog directory as shown below

image

Blog navigation display as shown below

image

deployment

Nginx reverse proxy configuration file reference

HTTP protocol

server {
     listen 80;
     listen [::]:80;
     server_name yourhost.com;

     location / {
          proxy_pass http://127.0.0.1:5006;
          proxy_set_header Host $host;
          proxy_set_header X-Real-IP $remote_addr;
          proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
      }
}

HTTPS protocol (port 80 automatically jumps to 443)

server {
     listen 80;
     listen [::]:80;
     server_name yourhost.com;

     location / {
         rewrite ^ https://$host$request_uri? permanent;
     }
}

server {
     listen 443 ssl;
     server_name yourhost.com;
     access_log /var/log/nginx/markdown-blog.access.log main;


     #Certificate file name
     ssl_certificate /etc/nginx/certs/yourhost.com_bundle.crt;
     #Private key file name
     ssl_certificate_key /etc/nginx/certs/yourhost.com.key;
     ssl_session_timeout 5m;
     ssl_protocols TLSv1.2 TLSv1.3;
     ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:HIGH:!aNULL:!MD5:!RC4:!DHE;
     ssl_prefer_server_ciphers on;

     location / {
          proxy_pass http://127.0.0.1:5006;
          proxy_set_header Host $host;
          proxy_set_header X-Real-IP $remote_addr;
          proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
      }
  }

upgrade

  1. Download the latest version release

  2. Stop the program, decompress and replace markdown-blog

  3. Restart the program

development

  1. Install Golang development environment

  2. Fork source code

  3. Start the web service

    After running, visit the address http://localhost:5006, and the API request will be forwarded to markdown-blog program

    make run
    
  4. Compile

    Generate the compressed package of the current system in the bin directory, such as: markdown-blog-v1.1.0-darwin-amd64.tar

    make
    
  5. Pack

    Generate the compressed package of the current system in the package directory, such as: markdown-blog-v1.1.0-darwin-amd64.tar

    make package
    
  6. Generate compressed packages for Windows, Linux, and Mac

    Generate a compressed package in package, such as: markdown-blog-v1.1.0-darwin-amd64.tar markdown-blog-v1.1.0-linux-amd64.tar.gz markdown-blog-v1.1.0-windows- amd64.zip

    make package-all
    

Feedback

  • If you encounter problems in the project, you can find answers in issues or ask questions directly
  • If you have any suggestions and ideas, you can start a discussion in discussions

Sponsors

  • Thanks to JetBrains for supporting this project!

License

This project adopts the MIT open source license, and the complete authorization description has been placed in the LICENSE file.