<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: MuYunyun</title>
    <description>The latest articles on DEV Community by MuYunyun (@muyunyun).</description>
    <link>https://dev.to/muyunyun</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F142567%2F5f3b5409-f92e-4fc6-9745-9050b3cc28d1.png</url>
      <title>DEV Community: MuYunyun</title>
      <link>https://dev.to/muyunyun</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/muyunyun"/>
    <language>en</language>
    <item>
      <title>SEO practice in SPA site </title>
      <dc:creator>MuYunyun</dc:creator>
      <pubDate>Sun, 14 Mar 2021 05:28:44 +0000</pubDate>
      <link>https://dev.to/muyunyun/seo-practice-in-spa-site-3mli</link>
      <guid>https://dev.to/muyunyun/seo-practice-in-spa-site-3mli</guid>
      <description>&lt;h3&gt;
  
  
  Background
&lt;/h3&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/http%3A%2F%2Fwith.muyunyun.cn%2Fc03d8772da6d57e47c55044aee364103.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/http%3A%2F%2Fwith.muyunyun.cn%2Fc03d8772da6d57e47c55044aee364103.jpg"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Observe that &lt;a href="http://muyunyun.cn/create-react-doc/" rel="noopener noreferrer"&gt;document site&lt;/a&gt; built based on &lt;a href="https://github.com/MuYunyun/create-react-doc" rel="noopener noreferrer"&gt;create-react-doc&lt;/a&gt;, I found the webpage code is bare(see the picture below). This is obviously a common problem of single-page application (SPA) sites. It is not conducive to be searched by search engines (SEO).&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/http%3A%2F%2Fwith.muyunyun.cn%2F0ba88a7544efe0e1978e6c8d8b7775a6.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/http%3A%2F%2Fwith.muyunyun.cn%2F0ba88a7544efe0e1978e6c8d8b7775a6.jpg"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Isn't it possible that SPA sites can't perform SEO, so what about frameworks such as &lt;a href="https://github.com/gatsbyjs/gatsby" rel="noopener noreferrer"&gt;Gatsby&lt;/a&gt;, &lt;a href="https://github.com/nuxt/nuxt.js" rel="noopener noreferrer"&gt;nuxt&lt;/a&gt; It can be used as the first choice for many bloggers to build blogs. What are the technical principles of such frameworks to empower SEO? Driven by curiosity, I start my journey of empowering SEO in &lt;a href="https://github.com/MuYunyun/create-react-doc" rel="noopener noreferrer"&gt;creat-react-doc&lt;/a&gt;.&lt;/p&gt;

&lt;h3&gt;
  
  
  Search Engine Optimization
&lt;/h3&gt;

&lt;p&gt;Before practice, let's analyze why single-page applications cannot be searched by search engines. The core is that &lt;code&gt;the crawler spider will not execute the JavaScript logic in the webpage during the crawling process&lt;/code&gt;, so &lt;code&gt;the jump logic hidden in the JavaScript will not be executed either&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;Check the packaged code of the current SPA site. Except for a root directory index.html, everything else is injected with JavaScript logic, so the browser will naturally not perform SEO on it.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/http%3A%2F%2Fwith.muyunyun.cn%2F0d15d4e3a62516da7c301e8f1c9228d6.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/http%3A%2F%2Fwith.muyunyun.cn%2F0d15d4e3a62516da7c301e8f1c9228d6.jpg"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;In addition, detailed search engine optimization is a more complicated subject. If you are new to SEO optimization, it is recommended to read &lt;a href="https://developers.google.com/search/docs/beginner/seo-starter-guide" rel="noopener noreferrer"&gt;Search Engine Optimization (SEO) Beginner's Guide&lt;/a&gt; article, given by Google Search Center. There are a comprehensive list of &lt;strong&gt;17&lt;/strong&gt; best practices, and &lt;strong&gt;33&lt;/strong&gt; practices that should be avoided.&lt;/p&gt;

&lt;h3&gt;
  
  
  Practical case of SEO in SPA site
&lt;/h3&gt;

&lt;p&gt;In the context of the light document site, we do not consider the SSR scheme for the time being.&lt;/p&gt;

&lt;p&gt;After investigating the SEO schemes of document sites on the market, the author summarizes the following four categories:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Static template rendering scheme&lt;/li&gt;
&lt;li&gt;404 redirection scheme&lt;/li&gt;
&lt;li&gt;SSG plan&lt;/li&gt;
&lt;li&gt;Pre-rendering scheme&lt;/li&gt;
&lt;/ul&gt;

&lt;h4&gt;
  
  
  Static template rendering scheme
&lt;/h4&gt;

&lt;p&gt;&lt;a href="https://github.com/hexojs/hexo" rel="noopener noreferrer"&gt;hexo&lt;/a&gt; is the most typical in the static template rendering scheme. Such frameworks need to specify a specific template language (such as &lt;a href="https://github.com/pugjs/pug" rel="noopener noreferrer"&gt;pug&lt;/a&gt;) to develop themes, so as to achieve the purpose of direct output of web content.&lt;/p&gt;

&lt;h4&gt;
  
  
  404 Redirection Scheme
&lt;/h4&gt;

&lt;p&gt;The principle of the 404 redirect solution is mainly to use the 404 mechanism of GitHub Pages for redirection. Typical cases are &lt;a href="https://github.com/rafgraph/spa-github-pages" rel="noopener noreferrer"&gt;spa-github-pages&lt;/a&gt;, &lt;a href="https://github.com/csuwildcat/sghpa" rel="noopener noreferrer"&gt;sghpa&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;But unfortunately, in 2019 Google &lt;a href="https://github.com/rafgraph/spa-github-pages#seo" rel="noopener noreferrer"&gt;adjusted crawler algorithm&lt;/a&gt;, so this kind of redirection scheme is not conducive to SEO at the moment. The author of spa-github-pages also stated that if SEO is required, use the SSG plan or the paid plan &lt;a href="https://www.netlify.com/blog/2020/04/07/creating-better-more-predictable-redirect-rules-for-spas/" rel="noopener noreferrer"&gt;Netlify&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/http%3A%2F%2Fwith.muyunyun.cn%2Fbbb5ed8bce1e0c08dae94df98ff33262.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/http%3A%2F%2Fwith.muyunyun.cn%2Fbbb5ed8bce1e0c08dae94df98ff33262.jpg"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h4&gt;
  
  
  SSG plan
&lt;/h4&gt;

&lt;p&gt;The full name of the SSG scheme is called &lt;code&gt;static site generator&lt;/code&gt;. In the community, &lt;a href="https://github.com/nuxt/nuxt.js" rel="noopener noreferrer"&gt;nuxt&lt;/a&gt;, &lt;a href="https://github.com/gatsbyjs/gatsby" rel="noopener noreferrer"&gt;Gatsby&lt;/a&gt; and other framework-enabling SEO technologies can be classified without exception such SSG schemes.&lt;/p&gt;

&lt;p&gt;Taking the nuxt framework as an example, based on the &lt;code&gt;conventional routing&lt;/code&gt;, it converts vue files into static web pages by executing the &lt;code&gt;nuxt generate&lt;/code&gt; command.&lt;/p&gt;

&lt;p&gt;example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;-| pages/
&lt;span class="nt"&gt;---&lt;/span&gt;| about.vue/
&lt;span class="nt"&gt;---&lt;/span&gt;| index.vue/
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;After being static, it becomes:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;-| dist/
&lt;span class="nt"&gt;---&lt;/span&gt;| about/
&lt;span class="nt"&gt;-----&lt;/span&gt;| index.html
&lt;span class="nt"&gt;---&lt;/span&gt;| index.html
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;After the routing is static, the document directory structure at this time can be hosted by any static site service provider.&lt;/p&gt;

&lt;h4&gt;
  
  
  Pre-rendering scheme
&lt;/h4&gt;

&lt;p&gt;After the above analysis of the SSG scheme, at this time the key to optimization of the SPA site is already on paper —— &lt;code&gt;static routing&lt;/code&gt;. Compared with frameworks such as nuxt and Gatsby, which have the limitation of conventional routing, &lt;a href="https://github.com/MuYunyun/create-react-doc" rel="noopener noreferrer"&gt;create-react-doc&lt;/a&gt; has flexible and free organization in the directory structure. Its website building concept is &lt;code&gt;File is Site&lt;/code&gt;, and it is also very convenient to migrate existing markdown documents.&lt;/p&gt;

&lt;p&gt;Take &lt;a href="https://github.com/MuYunyun/blog" rel="noopener noreferrer"&gt;blog&lt;/a&gt; project structure as an example, the document structure is as follows:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;-| BasicSkill/
&lt;span class="nt"&gt;---&lt;/span&gt;| basic/
&lt;span class="nt"&gt;-----&lt;/span&gt;| DOM.md
&lt;span class="nt"&gt;-----&lt;/span&gt;| HTML5.md
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;It should become:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;-| BasicSkill/
&lt;span class="nt"&gt;---&lt;/span&gt;| basic/
&lt;span class="nt"&gt;-----&lt;/span&gt;| DOM
&lt;span class="nt"&gt;-------&lt;/span&gt;| index.html
&lt;span class="nt"&gt;-----&lt;/span&gt;| HTML5
&lt;span class="nt"&gt;-------&lt;/span&gt;| index.html
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;After investigation, the idea and the &lt;a href="https://github.com/chrisvfritz/prerender-spa-plugin" rel="noopener noreferrer"&gt;prerender-spa-plugin&lt;/a&gt; pre-rendering solution hit it off. The principle of the pre-rendering scheme can be seen in the following figure:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/http%3A%2F%2Fwith.muyunyun.cn%2Ff3eb18c162a31fb155fd9f4a364f7fb9.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/http%3A%2F%2Fwith.muyunyun.cn%2Ff3eb18c162a31fb155fd9f4a364f7fb9.jpg"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;So far, the technology selection is determined to use the pre-rendering scheme to achieve SSG.&lt;/p&gt;

&lt;h3&gt;
  
  
  Pre-rendering program practice
&lt;/h3&gt;

&lt;p&gt;A brief overview of the steps of create-react-doc's practice in the pre-rendering solution is as follows (for complete changes, see &lt;a href="https://github.com/MuYunyun/create-react-doc/pull/95/files" rel="noopener noreferrer"&gt;mr&lt;/a&gt;):&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Transform hash routing to history routing. Because the history routing structure naturally matches the document static directory structure.
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight diff"&gt;&lt;code&gt;&lt;span class="p"&gt;export default function RouterRoot() {
&lt;/span&gt;  return (
&lt;span class="gd"&gt;-&amp;lt;HashRouter&amp;gt;
&lt;/span&gt;&lt;span class="gi"&gt;+ &amp;lt;BrowserRouter&amp;gt;
&lt;/span&gt;      &amp;lt;RoutersContainer /&amp;gt;
&lt;span class="gd"&gt;-&amp;lt;/HashRouter&amp;gt;
&lt;/span&gt;&lt;span class="gi"&gt;+ &amp;lt;/BrowserRouter&amp;gt;
&lt;/span&gt;  )
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;Added &lt;code&gt;pre-rendering environment&lt;/code&gt; on the basis of development environment and generation environment, and matched the routing environment at the same time. It mainly solves the correspondence between &lt;code&gt;resource files&lt;/code&gt; and &lt;code&gt;sub-paths under the main domain name&lt;/code&gt;. The process is tortuous, and interested friends can see &lt;a href="https://github.com/chrisvfritz/prerender-spa-plugin/issues/215#issuecomment-415942268" rel="noopener noreferrer"&gt;issue&lt;/a&gt;.
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight diff"&gt;&lt;code&gt;&lt;span class="p"&gt;const ifProd = env ==='prod'
&lt;/span&gt;&lt;span class="gi"&gt;+ const ifPrerender = window.__PRERENDER_INJECTED &amp;amp;&amp;amp; window.__PRERENDER_INJECTED.prerender
+ const ifAddPrefix = ifProd &amp;amp;&amp;amp; !ifPrerender
&lt;/span&gt;&lt;span class="err"&gt;
&lt;/span&gt;&amp;lt;Route
  key={item.path}
  exact
&lt;span class="gd"&gt;-path={item.path}
&lt;/span&gt;&lt;span class="gi"&gt;+ path={ifAddPrefix? `/${repo}${item.path}`: item.path}
&lt;/span&gt;  render={() =&amp;gt; {... }}
/&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;Compatible with the use of prerender-spa-plugin in webpack 5.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The official version currently does not support webpack 5, see &lt;a href="https://github.com/chrisvfritz/prerender-spa-plugin/issues/414" rel="noopener noreferrer"&gt;issue&lt;/a&gt; for details, and I have a need to execute callbacks after pre-rendering. Therefore, a copy of &lt;a href="https://github.com/create-react-doc/prerender-spa-plugin" rel="noopener noreferrer"&gt;version&lt;/a&gt; is currently forked, which solves the above problems.&lt;/p&gt;

&lt;p&gt;After the practice of the above steps, &lt;a href="https://github.com/MuYunyun/blog/tree/gh-pages" rel="noopener noreferrer"&gt;static routing&lt;/a&gt; is finally implemented in the SPA site.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/http%3A%2F%2Fwith.muyunyun.cn%2Fbf01633af158d460ca2830ed640e07cb.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/http%3A%2F%2Fwith.muyunyun.cn%2Fbf01633af158d460ca2830ed640e07cb.jpg"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  SEO optimization with additional buff, the site opens in seconds?
&lt;/h3&gt;

&lt;p&gt;SEO optimization so far, let's look at the changes in &lt;code&gt;FP&lt;/code&gt;, &lt;code&gt;FCP&lt;/code&gt;, &lt;code&gt;LCP&lt;/code&gt; and other indicator data before and after site optimization.&lt;/p&gt;

&lt;p&gt;Taking the &lt;a href="https://muyunyun.cn/blog" rel="noopener noreferrer"&gt;blog&lt;/a&gt; site as an example, the index data before and after optimization is as follows:&lt;/p&gt;

&lt;p&gt;Before optimization: Before accessing the pre-rendering scheme, the time node for the first drawing (FP, FCP) is about &lt;code&gt;8s&lt;/code&gt;, and the LCP is about 17s.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/http%3A%2F%2Fwith.muyunyun.cn%2F23d56cc42fd778c23d8ed80331334343.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/http%3A%2F%2Fwith.muyunyun.cn%2F23d56cc42fd778c23d8ed80331334343.jpg"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;After optimization: After accessing the pre-rendering scheme, the first drawing time node starts within &lt;code&gt;1s&lt;/code&gt;, and the LCP is within 1.5s.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/http%3A%2F%2Fwith.muyunyun.cn%2F9c551d29943c3d76700782374d86c37b.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/http%3A%2F%2Fwith.muyunyun.cn%2F9c551d29943c3d76700782374d86c37b.jpg"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Comparing the optimization between before and after: the first screen drawing speed has been increased by &lt;code&gt;8&lt;/code&gt; times, and the maximum content drawing speed has been increased by &lt;code&gt;11&lt;/code&gt; times. I wanted to optimize SEO, but I got another way to optimize site performance.&lt;/p&gt;

&lt;h3&gt;
  
  
  Generate Sitemap Sitemap
&lt;/h3&gt;

&lt;p&gt;After finishing the pre-rendering and realizing the static routing of the site, it is one step closer to the goal of SEO. Putting aside &lt;a href="https://developers.google.com/search/docs/beginner/seo-starter-guide" rel="noopener noreferrer"&gt;SEO optimization details&lt;/a&gt; for the time being, go straight to the core hinterland of SEO &lt;a href="https://developers.google.com/search/docs/advanced/sitemaps/overview" rel="noopener noreferrer"&gt;site map&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;The format of Sitemap and the meaning of each field are briefly explained as follows:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight xml"&gt;&lt;code&gt;&lt;span class="cp"&gt;&amp;lt;?xml version="1.0" encoding="utf-8"?&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;urlset&amp;gt;&lt;/span&gt;
  &lt;span class="c"&gt;&amp;lt;!-- Required tag, this is the definition entry of a specific link, each piece of data must be included with &amp;lt;url&amp;gt; and &amp;lt;/url&amp;gt;, this is required --&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;url&amp;gt;&lt;/span&gt;
    &lt;span class="c"&gt;&amp;lt;!-- Required, URL link address, length must not exceed 256 bytes --&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;loc&amp;gt;&lt;/span&gt;http://www.yoursite.com/yoursite.html&lt;span class="nt"&gt;&amp;lt;/loc&amp;gt;&lt;/span&gt;
    &lt;span class="c"&gt;&amp;lt;!-- You don't need to submit the tag, which is used to specify the last update time of the link --&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;lastmod&amp;gt;&lt;/span&gt;2021-03-06&lt;span class="nt"&gt;&amp;lt;/lastmod&amp;gt;&lt;/span&gt;
    &lt;span class="c"&gt;&amp;lt;!-- You don't need to submit the tag, use this tag to tell the update frequency of this link --&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;changefreq&amp;gt;&lt;/span&gt;daily&lt;span class="nt"&gt;&amp;lt;/changefreq&amp;gt;&lt;/span&gt;
    &lt;span class="c"&gt;&amp;lt;!-- You don’t need to submit the tag, which is used to specify the priority ratio of this link to other links. This value is set between 0.0-1.0 --&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;priority&amp;gt;&lt;/span&gt;0.8&lt;span class="nt"&gt;&amp;lt;/priority&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;/url&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;/urlset&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;blockquote&gt;
&lt;p&gt;In the above sitemap, the lastmod, changefreq, and priority fields are not so important for SEO, see &lt;a href="https://ahrefs.com/blog/zh/how-to-create-a%20-sitemap/" rel="noopener noreferrer"&gt;how-to-create-a-sitemap&lt;/a&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;According to the above structure, I developed the sitemap generation package &lt;a href="https://github.com/MuYunyun/create-react-doc/tree/main/packages/crd-generator-sitemap" rel="noopener noreferrer"&gt;crd-generator-sitemap&lt;/a&gt;, the logic is to splice the pre-rendered routing path into the above format.&lt;/p&gt;

&lt;p&gt;The user only needs to add the following parameters in the site root directory &lt;code&gt;config.yml&lt;/code&gt; to automatically generate &lt;a href="http://muyunyun.cn/create-react-doc/sitemap.xml" rel="noopener noreferrer"&gt;sitemap&lt;/a&gt; during the automatic release process.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;seo:
  google: &lt;span class="nb"&gt;true&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Submit the generated sitemap to &lt;a href="https://search.google.com/search-console/sitemaps" rel="noopener noreferrer"&gt;Google Search Console&lt;/a&gt; for a try,&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/http%3A%2F%2Fwith.muyunyun.cn%2F97c21838a1e3310b3c1259e30ab85f3b.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/http%3A%2F%2Fwith.muyunyun.cn%2F97c21838a1e3310b3c1259e30ab85f3b.jpg"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Finally, verify the before and after optimization of Google search &lt;a href="https://www.google.com/search?q=site%3Amuyunyun.cn%2Fcreate-react-doc&amp;amp;ie=UTF-8" rel="noopener noreferrer"&gt;site&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Before optimization: Only one piece of data is found.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/http%3A%2F%2Fwith.muyunyun.cn%2Faea3401e5a31587deb8d93a14f32b011.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/http%3A%2F%2Fwith.muyunyun.cn%2Faea3401e5a31587deb8d93a14f32b011.jpg"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;After optimization: Search the location data declared in the site map.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/http%3A%2F%2Fwith.muyunyun.cn%2F6df1536366c7d45e0f6418af03a7d948.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/http%3A%2F%2Fwith.muyunyun.cn%2F6df1536366c7d45e0f6418af03a7d948.jpg"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;So far, the complete process of using SSG to optimize SPA sites to achieve SEO has been fully realized. Follow-up is left to refer to the &lt;a href="https://developers.google.com/search/docs/beginner/seo-starter-guide" rel="noopener noreferrer"&gt;Search Engine Optimization (SEO) Beginner's Guide&lt;/a&gt; to optimize some SEO details and support more searches The engine is up.&lt;/p&gt;

&lt;h3&gt;
  
  
  Summary
&lt;/h3&gt;

&lt;p&gt;This article starts with the realization of SEO on the SPA site, and successively introduces the basic principles of SEO, four practical cases of SEO in the SPA site, combined with &lt;a href="https://github.com/MuYunyun/create-react-doc" rel="noopener noreferrer"&gt;create-react-doc&lt;/a&gt; SPA framework for complete SEO practice.&lt;/p&gt;

&lt;p&gt;If this article is helpful to you, welcome &lt;a href="https://github.com/MuYunyun/create-react-doc" rel="noopener noreferrer"&gt;star&lt;/a&gt;, &lt;a href="https://github.com/MuYunyun/create-react-doc/issues/new" rel="noopener noreferrer"&gt;feedback&lt;/a&gt;.&lt;/p&gt;

&lt;h3&gt;
  
  
  Related Links
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://github.com/MuYunyun/create-react-doc" rel="noopener noreferrer"&gt;create-react-doc&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://ahrefs.com/blog/zh/why-is-my-website-not-showing-up-on-%20google/" rel="noopener noreferrer"&gt;why-is-my-website-not-showing-up-on-google/&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://medium.com/frontend-digest/a-technical-guide-to-seo-with-gatsby-js-e88a7dac80f0" rel="noopener noreferrer"&gt;A Technical Guide to SEO With Gatsby.js&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>seo</category>
      <category>react</category>
      <category>vue</category>
    </item>
    <item>
      <title>Create React Doc: A Markdown Doc Site Generator For React</title>
      <dc:creator>MuYunyun</dc:creator>
      <pubDate>Sun, 05 Jul 2020 19:52:43 +0000</pubDate>
      <link>https://dev.to/muyunyun/create-react-doc-write-markdown-site-with-no-build-configuration-hk7</link>
      <guid>https://dev.to/muyunyun/create-react-doc-write-markdown-site-with-no-build-configuration-hk7</guid>
      <description>&lt;h1&gt;
  
  
  Create React Doc
&lt;/h1&gt;

&lt;p&gt;&lt;a href="https://github.com/MuYunyun/create-react-doc"&gt;Create React Doc&lt;/a&gt; is a markdown doc site generator for React. You can write markdown sites or blogs with no build configuration just like create-react-app.&lt;/p&gt;

&lt;h2&gt;
  
  
  Features
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Write markdown docs with no build configuration.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;Lazy load&lt;/code&gt; for markdown data.&lt;/li&gt;
&lt;li&gt;Generate menu autoly based file directory.&lt;/li&gt;
&lt;li&gt;Support deploy to &lt;a href="https://pages.github.com/"&gt;GitHub Pages&lt;/a&gt;.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Sites built with create-react-doc
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--4vL15N5V--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://user-images.githubusercontent.com/19354791/86540953-577ce500-bf3b-11ea-8dc5-1728d08d46cc.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--4vL15N5V--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://user-images.githubusercontent.com/19354791/86540953-577ce500-bf3b-11ea-8dc5-1728d08d46cc.png" alt=""&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;a href="http://muyunyun.cn/blog"&gt;muyunyun's blog&lt;/a&gt; &lt;a href="https://github.com/MuYunyun/blog"&gt;(github)&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;&lt;a href="http://muyunyun.cn/create-react-doc"&gt;create react doc&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Quick Overview
&lt;/h2&gt;



&lt;div class="highlight"&gt;&lt;pre class="highlight shell"&gt;&lt;code&gt;npx create-react-doc my-doc
npm &lt;span class="nb"&gt;install&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class="nb"&gt;cd &lt;/span&gt;my-doc
npm start
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;Then open &lt;a href=""&gt;http://localhost:3000/&lt;/a&gt; to see your doc.&lt;br&gt;
When you're ready to deploy to production, create a minified bundle with npm run build.&lt;/p&gt;
&lt;h2&gt;
  
  
  Usage
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://github.com/MuYunyun/create-react-doc"&gt;create-react-doc&lt;/a&gt; is very easy to use. You don’t need to install or configure tools like webpack or Babel. They are preconfigured and hidden so that you can focus on the code.&lt;/p&gt;

&lt;p&gt;You only install it as a package so that you can create your own website or blog. You may&lt;br&gt;
 choose one of the following methods:&lt;/p&gt;
&lt;h3&gt;
  
  
  npx
&lt;/h3&gt;


&lt;div class="highlight"&gt;&lt;pre class="highlight shell"&gt;&lt;code&gt;npx create-react-doc my-doc
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;h3&gt;
  
  
  npm
&lt;/h3&gt;


&lt;div class="highlight"&gt;&lt;pre class="highlight shell"&gt;&lt;code&gt;npm init create-react-doc my-doc
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;h3&gt;
  
  
  yarn
&lt;/h3&gt;


&lt;div class="highlight"&gt;&lt;pre class="highlight shell"&gt;&lt;code&gt;yarn create create-react-doc my-doc
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;


&lt;p&gt;Once the installation is done, you can open your project folder:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;npm install &amp;amp;&amp;amp; cd my-doc
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;Inside the newly created project, you can run some built-in commands:&lt;/p&gt;

&lt;h3&gt;
  
  
  &lt;code&gt;npm start&lt;/code&gt; or &lt;code&gt;yarn start&lt;/code&gt;
&lt;/h3&gt;

&lt;p&gt;Runs the doc in development mode.&lt;br&gt;
Open &lt;a href=""&gt;http://localhost:3000&lt;/a&gt; to view it in the browser.&lt;/p&gt;

&lt;p&gt;The page will automatically reload if you make changes to the code.&lt;/p&gt;
&lt;h3&gt;
  
  
  &lt;code&gt;npm run build&lt;/code&gt; or &lt;code&gt;yarn build&lt;/code&gt;
&lt;/h3&gt;

&lt;p&gt;Builds the doc for production to the build folder.&lt;br&gt;
It correctly bundles React in production mode and optimizes the build for the best performance.&lt;/p&gt;

&lt;p&gt;The build is minified and the filenames include the hashes.&lt;/p&gt;

&lt;p&gt;Your doc site is ready to be deployed.&lt;/p&gt;
&lt;h3&gt;
  
  
  &lt;code&gt;npm run deploy&lt;/code&gt; or &lt;code&gt;yarn deploy&lt;/code&gt;
&lt;/h3&gt;

&lt;p&gt;The doc'll deployed to GitHub Pages rely &lt;code&gt;user&lt;/code&gt;, &lt;code&gt;repo&lt;/code&gt; in &lt;a href="https://github.com/MuYunyun/create-react-doc#configyml"&gt;config.yml&lt;/a&gt;&lt;/p&gt;
&lt;h2&gt;
  
  
  config.yml
&lt;/h2&gt;

&lt;p&gt;There is some configuration provided for you to adjust doc sites.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# Site title&lt;/span&gt;
title: Time Flying

&lt;span class="c"&gt;# Witch files to show as Menu&lt;/span&gt;
&lt;span class="c"&gt;## you can also set detailed dir, such as BasicSkill/css&lt;/span&gt;
menu: React,BasicSkill,Algorithm
&lt;span class="c"&gt;## set init open menu keys&lt;/span&gt;
menuOpenKeys: /BasicSkill

&lt;span class="c"&gt;# Github&lt;/span&gt;
&lt;span class="c"&gt;## if you want to show editing pages on github or deploy to GitHub Pages, you should config these arguments.&lt;/span&gt;
user: MuYunyun
repo: blog
branch: master            &lt;span class="c"&gt;# the default value of branch is master&lt;/span&gt;
deploy_branch: gh-pages   &lt;span class="c"&gt;# which branch to deploy.(default: gh-pages)&lt;/span&gt;
&lt;span class="c"&gt;# publish:                # if you want upload to gitlab or other git platform, you can set full git url in it&lt;/span&gt;

&lt;span class="c"&gt;# Available values: en| zh-cn&lt;/span&gt;
language: en
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;h2&gt;
  
  
  Advanced Usage
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;If you not want to show some private files, you can set it in &lt;code&gt;.gitignore&lt;/code&gt;, and the file'll be ignored to show in the docs.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;It'll provide more features in the future, looking forward to your comment &lt;a href="https://github.com/MuYunyun/create-react-doc/issues/new"&gt;there&lt;/a&gt;!&lt;/p&gt;

&lt;p&gt;Thank your read very much.&lt;/p&gt;

</description>
      <category>markdown</category>
      <category>blog</category>
    </item>
    <item>
      <title>The Annual Summary Of 2019</title>
      <dc:creator>MuYunyun</dc:creator>
      <pubDate>Sat, 04 Jan 2020 15:05:42 +0000</pubDate>
      <link>https://dev.to/muyunyun/the-annual-summary-of-2019-1pdd</link>
      <guid>https://dev.to/muyunyun/the-annual-summary-of-2019-1pdd</guid>
      <description>&lt;p&gt;Time is flying, it arrives at the end of year again. This is my first year working in PinDuoDuo inc and it seems I arrive in the company yesterday. This point is a good chance to talk with(recognize) myself again. I try to conclude from &lt;code&gt;work&lt;/code&gt;, &lt;code&gt;output&lt;/code&gt;, &lt;code&gt;life&lt;/code&gt; and &lt;code&gt;destination&lt;/code&gt;.&lt;/p&gt;

&lt;h3&gt;
  
  
  Learn from work
&lt;/h3&gt;

&lt;p&gt;The first course I learn from my team is about &lt;code&gt;starting with the end&lt;/code&gt;. It means everything we do today is prepared for the tomorrow. In the other word, we should realize witch period the thing we're doing is in, and our team write summary every week to make sure the established goals become closer and closer.&lt;/p&gt;

&lt;p&gt;The second course I learn from the work is to try to &lt;code&gt;use English more&lt;/code&gt;. There are so much rich resource in Medium, MDN, Frontend Masters and even in twitter. It's the first time I met with so many foreigners engineer in the JSConf but I can't talk with them fluently. It's obviously using English skillfully will open your eyes and improve efficiency looking for some information.&lt;/p&gt;

&lt;p&gt;The last but most important is &lt;code&gt;how to communicate&lt;/code&gt;. It's artistic to describe something easily to make others understand. When arriving at our team at first, one of my leader's advice is the best way to join in the team is to share —— sharing ideas, knowldege and feeling. My colleagues are so excellent I learn a lot from them in these technical sharing parties every week. At the meanwhile I also share some ideas in it.&lt;/p&gt;

&lt;h3&gt;
  
  
  Output of the article
&lt;/h3&gt;

&lt;p&gt;There are ten new articles added to &lt;a href="https://github.com/MuYunyun/blog"&gt;my blog&lt;/a&gt;, the direction is to talk about React, JavaScript, CSS and so on. If there are mistakes in it, welcome &lt;a href="https://github.com/MuYunyun/blog/issues/new"&gt;point out&lt;/a&gt;.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="http://muyunyun.cn/posts/8b09c168/"&gt;Introduction To Functional Programming&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://muyunyun.cn/posts/9f41fc98/"&gt;Do Search In Data Structure Of React Fiber&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://muyunyun.cn/posts/44b01006/"&gt;Understand React Suspense deeply&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://muyunyun.cn/posts/ba7c84ae/"&gt;You don't know requestIdleCallback&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://muyunyun.cn/posts/290a4219/"&gt;Deep into React Hooks&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://muyunyun.cn/posts/a1be1d41/"&gt;How to make page run smoothly&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://muyunyun.cn/posts/32fb0f08/"&gt;Deep into React Hooks —— Design Pattern&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://muyunyun.cn/posts/76ba81e7/"&gt;Modern React test&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://muyunyun.cn/posts/8bdf2cdf/"&gt;Learn Controlled Component and Uncontrolled Component Again&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://muyunyun.cn/posts/33fba87f/"&gt;INHERITED AND NON-INHERITED IN CSS&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;There will be more creative articles to add in the future. Let's grow up together.&lt;/p&gt;

&lt;h3&gt;
  
  
  Life
&lt;/h3&gt;

&lt;p&gt;I enjoy the quiet time sitting in the Cafe the whole day in Saturday and it's also nice to chat with friends or family there.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--DTOqc9ql--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/http://with.muyunyun.cn/65758e96048af8ff1fd619ba1abc834a.jpg-400" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--DTOqc9ql--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/http://with.muyunyun.cn/65758e96048af8ff1fd619ba1abc834a.jpg-400" alt=""&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;And in other some weekend days, I take part in some FE conferences this year —— &lt;code&gt;FDConf&lt;/code&gt;, &lt;code&gt;VUE Conf&lt;/code&gt;, &lt;code&gt;D2&lt;/code&gt;, &lt;code&gt;SEE Conf&lt;/code&gt; and so on. From these activities I learn some some new knowledge. For example, the article &lt;a href="http://muyunyun.cn/posts/a1be1d41/"&gt;How to make page run smoothly&lt;/a&gt; is written after listening the sharing of Liu Bowen in FDConf. And luckily, I get the chance to take photo with &lt;a href="https://twitter.com/youyuxi"&gt;Evan You&lt;/a&gt; and get the&lt;br&gt;
signature from him.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--QnPWfHgc--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/http://with.muyunyun.cn/27a9372dcab28c9c15e1b273096b2680.jpg-300" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--QnPWfHgc--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/http://with.muyunyun.cn/27a9372dcab28c9c15e1b273096b2680.jpg-300" alt=""&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;At the same time, it's happy to meet with old friends and make with new friends in these activities.&lt;/p&gt;

&lt;h3&gt;
  
  
  Checklist &amp;amp;&amp;amp; Destination
&lt;/h3&gt;

&lt;p&gt;Checking the plan of last year before making plans in new year.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Reading &lt;code&gt;five&lt;/code&gt; technical books and a not technical book, &lt;del&gt;learn Functional Programming&lt;/del&gt;: It is a shame not achieve this target. Instead of reading the whole books, I read more single posts or chapters partly in the last year.&lt;/li&gt;
&lt;li&gt;Finishing &lt;del&gt;a valuable project&lt;/del&gt;: There are some valuable projects in my daily work, they're still in progress.&lt;/li&gt;
&lt;li&gt;
&lt;del&gt;Deep into &lt;code&gt;React&lt;/code&gt; community&lt;/del&gt;, submit a pr: There is some deep analyze in React this year, however it still needs making extra effort for making a pr;&lt;/li&gt;
&lt;li&gt;Deep &lt;del&gt;into the document of &lt;code&gt;Node.Js&lt;/code&gt;&lt;/del&gt;: the work of this year is connected with UI and component more closely, so the document of Node.Js has no much chance reading in practice;&lt;/li&gt;
&lt;li&gt;
&lt;del&gt;Improving the skill of communication, do a sharing in a party&lt;/del&gt;: The communication skill gets some improved, however it still needs be strengthened;&lt;/li&gt;
&lt;li&gt;&lt;del&gt;Invite friends fro coffee(at least 12)&lt;/del&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Keeping going on in the new year. Here lists some direction.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Keeping reading and writing. Creating more personal thoughts;&lt;/li&gt;
&lt;li&gt;Improving listening/writing skill in English continually;

&lt;ul&gt;
&lt;li&gt;Way: watching ten+ english movies and try to write some english posts.&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;
&lt;li&gt;Improving the basic skills in data structure and composition principle continually;&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>annualsummary</category>
    </item>
    <item>
      <title>INHERITED AND NON-INHERITED IN CSS</title>
      <dc:creator>MuYunyun</dc:creator>
      <pubDate>Sat, 07 Dec 2019 09:18:30 +0000</pubDate>
      <link>https://dev.to/muyunyun/inherited-and-non-inherited-in-css-mi4</link>
      <guid>https://dev.to/muyunyun/inherited-and-non-inherited-in-css-mi4</guid>
      <description>&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/http%3A%2F%2Fwith.muyunyun.cn%2Fb22bcdb94d354d3f301cae7997d9cd17.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/http%3A%2F%2Fwith.muyunyun.cn%2Fb22bcdb94d354d3f301cae7997d9cd17.jpg"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;When I look up css properties in MDN's specifications section, there are some properties in it and it seems unfamiliar to me. So I try to find out some of them today.&lt;/p&gt;

&lt;p&gt;The follow list try to give one word to specify the meaning of them.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Initial value: Specify the CSS property's default value;&lt;/li&gt;
&lt;li&gt;Applies to: Specify which elements to apply to;&lt;/li&gt;
&lt;li&gt;Inherited: Specify the CSS property is inherited or non-inherited;&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://www.w3.org/TR/css3-mediaqueries/" rel="noopener noreferrer"&gt;Media&lt;/a&gt;: Specify how a document is to be presented on different media;&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://developer.mozilla.org/en-US/docs/Web/CSS/computed_value" rel="noopener noreferrer"&gt;Computed value&lt;/a&gt;: The CSS property that is transferred from parent to child;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://drafts.csswg.org/web-animations/#animation-type" rel="noopener noreferrer"&gt;Animation type&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://developer.mozilla.org/en-US/docs/Glossary/Canonical_order" rel="noopener noreferrer"&gt;Canonical order&lt;/a&gt;: Some CSS properties(font、background...) have their own CSS property value order.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;And this article is to discuss the topic about the knowledge of inherited and non-inherited.&lt;/p&gt;

&lt;h3&gt;
  
  
  Initial value between inherited and non-inherited
&lt;/h3&gt;

&lt;p&gt;The initial value of a CSS property is its default value.&lt;/p&gt;

&lt;p&gt;The Initial value has two different behavior between &lt;code&gt;inherited properties&lt;/code&gt; and &lt;code&gt;non-inherited properties&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;For &lt;code&gt;inherited properties&lt;/code&gt;, the initial value is &lt;code&gt;used on the root element only&lt;/code&gt;.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight html"&gt;&lt;code&gt;&lt;span class="nt"&gt;&amp;lt;span&lt;/span&gt; &lt;span class="na"&gt;style=&lt;/span&gt;&lt;span class="s"&gt;"color: red"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
  hello, &lt;span class="nt"&gt;&amp;lt;em&amp;gt;&lt;/span&gt;CSS&lt;span class="nt"&gt;&amp;lt;/em&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;/span&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The result is the color of both &lt;code&gt;span&lt;/code&gt; and &lt;code&gt;em&lt;/code&gt; element are red. Because the color is an inherited property, the element will get the color property from the parent recursively until to document.&lt;/p&gt;

&lt;p&gt;For &lt;code&gt;non-inherited properties&lt;/code&gt;, the initial value is &lt;code&gt;used on every element&lt;/code&gt;. When no value for a non-inherited property has been specified on an element, the element gets the initial value directly.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight html"&gt;&lt;code&gt;&lt;span class="nt"&gt;&amp;lt;span&lt;/span&gt; &lt;span class="na"&gt;style=&lt;/span&gt;&lt;span class="s"&gt;"border: 1px solid black"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
  hello, &lt;span class="nt"&gt;&amp;lt;em&amp;gt;&lt;/span&gt;CSS&lt;span class="nt"&gt;&amp;lt;/em&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;/span&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The result is the border is only effected on &lt;code&gt;span&lt;/code&gt; element, not &lt;code&gt;em&lt;/code&gt;. Because the border is a non-inherited property, and there is no border property specified on the em, so the em get the border's initial value &lt;code&gt;none&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;It mentioned much times about inherited value and non-inherited value above, and now we sort out css properties.&lt;/p&gt;

&lt;h3&gt;
  
  
  Inherited Type
&lt;/h3&gt;

&lt;p&gt;I've collected some inherited types in css, they are listed as follow:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;Font Type&lt;/code&gt;: font-style、font-variant、font-weight、font-stretch、font-size、font-family、color、line-height;&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;Space Type&lt;/code&gt;: letter-spacing、word-spacing、white-space;&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;Letter Type&lt;/code&gt;: text-align、text-indent、text-shadow、text-transform;&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;List Type&lt;/code&gt;: list-style、list-style-type、list-style-position;&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;Others&lt;/code&gt;: visibility、cursor;&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Non-Inherited Type
&lt;/h3&gt;

&lt;p&gt;In the opposite of inherited type, the non-inherited types are listed as follow:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;Layout Type&lt;/code&gt;: float、position、left、right、top、bottom、z-index、display&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;Box Type&lt;/code&gt;: width、max-width、min-width、height、max-height、min-height、margin、padding、border;&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;Background Type&lt;/code&gt;: background-size、background-image、background-clip、background-color、background-origin、background-position、background-repeat;&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;Others&lt;/code&gt;: overflow、text-overflow、vertical-align;&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Recap
&lt;/h3&gt;

&lt;p&gt;These section introduces the inherited concept in CSS, and distinguish some inherited type and some non-inherited type from css properties. Hope it's helpful for you.&lt;/p&gt;

</description>
      <category>css</category>
    </item>
  </channel>
</rss>
