Is the image address of AnQiCMS relative or absolute? Does it affect usage?

As an experienced website operator who deeply understands the operation of the Anqin CMS, I know that every detail of content presentation may affect user experience and search engine optimization.About whether the image address in Anqi CMS is using a relative path or an absolute path, and its potential impact on website operation, I will give you a detailed explanation.

The mechanism of the AnQiCMS image path construction

AnQiCMS tends to use absolute paths in handling website image pathsAbsolute path (relative to the root directory of the domain)This means that when your website loads in the browser, the image address will usually be/Start, directly pointing to a specific file or folder under the root directory of the website.This design concept runs through all the content images, thumbnails, and static resources referenced in the system uploads.

For example, the address of an image uploaded through a content editor may be similar to/uploads/2023/07/my-image.jpg. Here,/uploadsThe folder is located where your website is deployedpublicand web servers such as Nginx or Apache usually placepublicThe directory is set as the root directory of the website. Therefore, when the browser parses to/uploads/...it will directly look for this resource from the root directory of the domain name.

For the static resources referenced in the template, such as CSS, JavaScript files, and images included in the template, the situation is similar. The document mentions that the template static resources are stored in/public/static/In the directory and through{% system with name="TemplateUrl" %}The tag retrieves the base URL of the template. This means that the references to static resources within the template (such as<img src="{% system with name="TemplateUrl" %}/images/logo.png">) will ultimately be resolved to such absolute paths, ensuring the accurate loading of resources./public/static/yourtemplate/images/logo.pngsuch paths, ensuring the accurate loading of resources.

Some image fields provided by the system, such as document details label (tag-/anqiapi-archive/142.html) in theLogoorThumb, and contact information label (tag-contact.md) in theQrcodeThey are also directly outputted as absolute paths that can be recognized by browsers, relative to the domain root directory, and can be used directly for<img>label'ssrcProperty.

It is worth mentioning that Anqi CMS also provides the function of whether to download remote images. If the content contains images from other domains (i.e., complete absolute URLs such ashttps://example.com/remote.jpgThe system can choose to download it to local storage and convert it to a local absolute path reference. This further reinforces the system's preference for local absolute paths.

This path management mode affects the use

Our CMS uses absolute paths (relative to the domain root directory) to manage image addresses, which is not a random choice but rather a consideration of many aspects such as website performance, maintainability, and search engine optimization. This model has the following main impacts on the daily operation and maintenance of the website:

First, inSearch Engine Optimization (SEO) aspectThe absolute path has significant advantages. Search engine crawlers tend to fetch and index resources with clear, stable URLs.Relative paths may cause ambiguity when the website structure changes or content is migrated, while absolute paths always point to the exact location of the resource, which helps to increase the probability of images being indexed by search engines and avoid failure in crawling due to path resolution errors.At the same time, the unified path structure also makes it easier for website administrators to monitor and manage image index situations in tools like Google Search Console.

Secondly, it greatly improvedContent portability and stability. No matter how you adjust the structure of your article or page, or the content is copied to different levels of the website, the image link will remain valid.For example, an article containing images starts from the first-level catalog/news/Moved to the second-level directory/archive/year/Image path/uploads/image.jpgIt can still be parsed correctly, while using a relative path../uploads/image.jpgThis may become invalid due to level changes. This reduces the problem of dead links caused by website structure adjustments and reduces the workload of operations personnel.

Moreover, absolute path managementSimplified front-end development and maintenance. Front-end developers do not need to worry about the impact of the current page depth on the image path, they can directly use the unified/uploads/...or/static/...Format reference resource, this reduces the complexity of path calculation and improves development efficiency.Especially when introducing JavaScript dynamic loading or handling images, absolute paths can provide clearer and more predictable resource location.

However, this pattern also brings someconsideration.deployment in multiple environmentswhen deploying in different environments such as local development, test, and production environments, if the domain names orpublicThe directory structure is not configured consistently, which may cause image loading to fail. Although the Anqi CMS'sBaseUrlSettings can help alleviate the problem to some extent, but operations personnel still need to ensure that the configuration of each environment can be correctly parsed