#### This Page

# `lektor.builder.``Artifact`

During the build process Lektor creates artifact objects to represent final build artifacts. Generally each Source Object will generate one artifact for which it acts as a primary source.

There are however many cases in which a source object will create sub-artifacts. For instance any thumbnail created in the context of a page will be creating its own artifact. To give plugins the same ability the artifact system is partially documented. See also sub_artifact to see how to create your own artifact instances.

The most important function of an artifact is open which can open the artifact for reading or writing. If the build goes well, Lektor will commit those changes and persist them.

## Example

    ctx = get_ctx()
    @ctx.sub_artifact('artifact.txt')
    def build_stylesheet(artifact):
        with artifact.open('w') as f:
            f.write('Hello World!\n')

#### artifact_name

The name of the artifact

#### is_current

Indicates if the artifact is up to date or needs building.

#### open()

Can open the artifact for reading or writing.

#### render_template_into()

Renders a template into the artifact.

#### replace_with_file()

Replaces the artifact with a file from the file system.

#### source_obj

A reference to the source object if available.

## Comments